Skip to content

Instantly share code, notes, and snippets.

@hroi
Created March 6, 2010 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hroi/323814 to your computer and use it in GitHub Desktop.
Save hroi/323814 to your computer and use it in GitHub Desktop.
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