I\'d like to implement this little code in Clojure, but I am struggling:
struct mystruct {
int id;
int price;
}
Jeremy's answer is good for how to do a for loop in idiomatic Clojure.
If you really want an imperative-style for loop in Clojure, you can create one with this macro:
(defmacro for-loop [[sym init check change :as params] & steps]
`(loop [~sym ~init value# nil]
(if ~check
(let [new-value# (do ~@steps)]
(recur ~change new-value#))
value#)))
Usage as follows:
(for-loop [i 0 (< i 10) (inc i)]
(println i))