Last active
November 10, 2017 10:43
-
-
Save rauhs/f71f30c195bc8bebc400c2f7275970ab to your computer and use it in GitHub Desktop.
This file contains hidden or 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 amap-inplace-new | |
| "Maps an expression across an array a, using an index named idx, and | |
| element el: | |
| (amap-inplace [[idx el] arr] | |
| [idx el])" | |
| [[[idx el] arr] & body] | |
| `(let [a# ~arr] | |
| (dotimes [~idx (alength a#)] | |
| (let [~el (aget a# ~idx)] | |
| (aset a# ~idx (do ~@body)))))) | |
| (defmacro afor | |
| "Like for but eagerly builds a JS array. | |
| Usually for react consumption." | |
| [[item coll] & body] | |
| `(reduce (fn [neue# ~item] | |
| (.push neue# (do ~@body)) | |
| neue#) | |
| (cljs.core/array) ~coll)) | |
| (defmacro set!! | |
| ([x v] | |
| (list 'js* "~{} = ~{}" x v)) | |
| ([x a0 v] | |
| (list 'js* "~{} = ~{}" (list '.. x a0) v)) | |
| ([x a0 a1 v] | |
| (list 'js* "~{} = ~{}" (list '.. x a0 a1) v)) | |
| ([x a0 a1 a2 v] | |
| (list 'js* "~{} = ~{}" (list '.. x a0 a1 a2) v))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment