Created
April 4, 2015 19:32
-
-
Save dgellow/287edd1a03b5f736d91c to your computer and use it in GitHub Desktop.
clojure's thread-last macro, aka ->>, in wisp | See https://clojuredocs.org/clojure.core/-%3E%3E
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 --> | |
[x & forms] | |
(let [next (fn [x] (let [r (rest x)] (if (empty? r) nil r)))] | |
(loop [x x, forms forms] | |
(if forms | |
(let [form (first forms) | |
threaded (if (list? form) | |
(with-meta | |
`(~(first form) ~@(next form) ~x) | |
(meta form)) | |
(list form x))] | |
(recur threaded (next forms))) | |
x)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment