Created
December 21, 2011 18:44
-
-
Save oehme/1507155 to your computer and use it in GitHub Desktop.
Arrays in Clojure, as non-functional as it gets ;)
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 foo [x] | |
(cond | |
(instance? Integer x) "Integer" | |
(instance? String x) "String" | |
(instance? Boolean x) "Boolean")) | |
(defn array-foo [n] | |
(let [items (object-array ["foo" 23 true]) result (object-array (* 3 n))] | |
(dotimes [i n] | |
(dotimes [j 3] | |
(aset result i | |
(foo (aget items j))))) | |
result)) | |
(time (prn (count (array-foo 10000000)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment