Skip to content

Instantly share code, notes, and snippets.

@alandipert
Forked from fogus/plet.clj
Created July 28, 2012 22:39
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 alandipert/3195036 to your computer and use it in GitHub Desktop.
Save alandipert/3195036 to your computer and use it in GitHub Desktop.
(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)))
@fogus
Copy link

fogus commented Jul 29, 2012

Changed the original to be a bit sleeker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment