Skip to content

Instantly share code, notes, and snippets.

@oliyh
Created June 17, 2015 12:57
Show Gist options
  • Save oliyh/bf98c3774b07cdf2572f to your computer and use it in GitHub Desktop.
Save oliyh/bf98c3774b07cdf2572f to your computer and use it in GitHub Desktop.
Combining Clojure macros some-> and as->
(defmacro someas->
"A mixture of some-> and as-> allowing more flexibility in the step forms"
[expr name & forms]
(let [pstep (fn [step] `(if (nil? ~name) nil ~step))]
`(let [~name ~expr
~@(interleave (repeat name) (map pstep forms))]
~name)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment