Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created February 18, 2014 22:33
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 amalloy/9081844 to your computer and use it in GitHub Desktop.
Save amalloy/9081844 to your computer and use it in GitHub Desktop.
(defmacro as->
"Binds name to expr, evaluates the first form in the lexical context
of that binding, then binds name to that result, repeating for each
successive form, returning the result of the last form."
{:added "1.5"}
[expr name & forms]
`(let [~name ~expr
~@(interleave (repeat name) (butlast forms))]
~(last forms)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment