clj->janet :: loop->clj-loop
This commit is contained in:
parent
a65b4ba873
commit
f4d09afed6
13
janet/clj-loop.janet
Normal file
13
janet/clj-loop.janet
Normal file
|
@ -0,0 +1,13 @@
|
|||
(defmacro clj-loop
|
||||
``A drop-in replacement for Clojure's loop form. Useful for the current project of converting Clojure code to Janet.
|
||||
``
|
||||
[bindings & body]
|
||||
(assert (even? (length bindings)))
|
||||
(def names @[])
|
||||
(def args @[])
|
||||
(loop [i :range [0 (length bindings)]]
|
||||
(if (even? i)
|
||||
(array/push names (get bindings i))
|
||||
(array/push args (get bindings i))))
|
||||
~(do (defn recur [,;names] ,;body) (recur ,;args)))
|
||||
|
Loading…
Reference in New Issue
Block a user