Created
January 17, 2017 00:13
-
-
Save michalmarczyk/1e624be27d6a6da690f2fdfbb47cb960 to your computer and use it in GitHub Desktop.
Clojure local shadowing, loop semantics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 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