Skip to content

Instantly share code, notes, and snippets.

@ExFed
Last active November 2, 2023 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ExFed/86fbf8c689bae000e7c5495a74c256dc to your computer and use it in GitHub Desktop.
Save ExFed/86fbf8c689bae000e7c5495a74c256dc to your computer and use it in GitHub Desktop.
Clojure Lineage Macro
(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