Created
April 24, 2011 15:17
-
-
Save gbarrancos/939616 to your computer and use it in GitHub Desktop.
Loop + Maping with a side effecty fn over a seq
This file contains 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
(defn side-effecty-fn [arg] | |
(print (str "Hit the fn: " arg "\n" )) | |
) | |
(defn loopy [begin end] | |
(loop [current begin] | |
(if (> current end) | |
"Done" | |
(do | |
(print (str "Calling with " current "\n")) | |
(dorun (map side-effecty-fn (cons current ["aaa" "bbb"]))) | |
(recur (inc current)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected: (loopy 2 3)
Calling with 2
Hit the fn: 2
Hit the fn: aaa
Hit the fn: bbb
Calling with 3
Hit the fn: 3
Hit the fn: aaa
Hit the fn: bbb
"Done"
Actual:
Calling with 2
Calling with 3
"Done"