Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clojure local shadowing, loop semantics
;;; See the comment threads here:
;;; http://stackoverflow.com/questions/41677617/are-all-variables-in-clojure-constant
(loop [x 1
f (fn [] x)]
(if (== 1 x)
(recur 0 f)
(f)))
;= 1
(loop [x 10
fs []]
(if (pos? x)
(recur (dec x)
(conj fs (fn [] x)))
(mapv #(%) fs)))
;= [10 9 8 7 6 5 4 3 2 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.