Skip to content

Instantly share code, notes, and snippets.

@oehme
Created December 21, 2011 17:54
Show Gist options
  • Save oehme/1506973 to your computer and use it in GitHub Desktop.
Save oehme/1506973 to your computer and use it in GitHub Desktop.
The faster Clojure version
(defn foo [x]
(cond
(instance? Integer x) "Integer"
(instance? String x) "String"
(instance? Boolean x) "Boolean"))
(defn transient-foo [n]
(loop [cnt n col (transient [])]
(if (= cnt 0) (persistent! col)
(recur (dec cnt)
(reduce #(conj! %1 (foo %2)) col ["foo" 23 true])))))
(time (prn (count (transient-foo 1000000))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment