Created
June 28, 2010 23:10
-
-
Save polypus74/456523 to your computer and use it in GitHub Desktop.
This file contains 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
(defmacro letp [expr bindings & body] | |
(let [parted | |
(partition 3 bindings) | |
true-bindings | |
(vec (apply concat | |
(map #(take 2 %) parted))) | |
false-bindings | |
(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]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
btw, the above returns [1 3]