-
-
Save alandipert/3195036 to your computer and use it in GitHub Desktop.
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
(defn deconstruct | |
([l] | |
(thisfn l [] [])) | |
([l vars values] | |
(if (seq l) | |
(recur (rest (rest l)) | |
(conj vars (first l)) | |
(conj values (first (rest l)))) | |
[vars values]))) | |
(defmacro letp [bindings & exprs] | |
(let [ret (deconstruct bindings) | |
vars (ret 0) | |
values (ret 1)] | |
`((fn ~vars ~@exprs) | |
~@values))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changed the original to be a bit sleeker.