Skip to content

Instantly share code, notes, and snippets.

@polypus74 polypus74/letp.clj
Created Jun 28, 2010

What would you like to do?
(defmacro letp [expr bindings & body]
(let [parted
(partition 3 bindings)
(vec (apply concat
(map #(take 2 %) parted)))
(vec (apply concat
(map #(list (first %) (last %)) parted)))]
`(if ~expr
(let ~true-bindings ~@body)
(let ~false-bindings ~@body))))
(letp true
[x 1 2
y 3 4]
[x y])

This comment has been minimized.

Copy link
Owner Author

polypus74 commented Jun 28, 2010

btw, the above returns [1 3]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.