Last active
November 2, 2023 03:53
-
-
Save ExFed/86fbf8c689bae000e7c5495a74c256dc to your computer and use it in GitHub Desktop.
Clojure Lineage Macro
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 linas-> | |
"Similar to clojure.core/as->; returns a vector of intermediate values." | |
[expr name & forms] | |
(let [linn `lin#] | |
`(let [~name ~expr | |
~linn [~name] | |
~@(interleave (repeat name) (butlast forms) (repeat linn) (repeat `(conj ~linn ~name)))] | |
~(if (empty? forms) | |
[name] | |
`(conj ~linn ~(last forms)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment