Created
October 4, 2015 14:32
-
-
Save nasser/6606145533dd60dacfaa to your computer and use it in GitHub Desktop.
doarray clojure iteration
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
(defmacro doarray [[variable array] & body] | |
(let [i (with-meta (gensym "i") {:tag Int64}) | |
var-type (or (-> variable meta :tag) 'Object) | |
arr-type (symbol->array-type var-type) | |
arr (with-meta (gensym "array") {:tag arr-type})] | |
`(let [~arr ~array] | |
(loop [~i 0] | |
(if (= ~i (.Length ~arr)) | |
nil | |
(let [~variable (aget ~arr ~i)] | |
~@body | |
(recur (inc ~i)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment