Created
March 6, 2010 17:30
-
-
Save hroi/323814 to your computer and use it in GitHub Desktop.
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
user> (time (reduce + (loop [foo 0 bar '()] | |
(if (= foo 1000000) | |
bar | |
(recur (inc foo) (cons foo bar)))))) | |
"Elapsed time: 912.220229 msecs" | |
499999500000 | |
user> (time (reduce + (loop [foo 0 bar (transient [])] | |
(if (= foo 1000000) | |
(persistent! bar) | |
(recur (inc foo) (conj! bar foo)))))) | |
"Elapsed time: 502.656015 msecs" | |
499999500000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment