ludus/janet/clj-loop.janet

14 lines
427 B
Plaintext
Raw Normal View History

2024-01-11 19:26:22 +00:00
(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)))