Created
March 29, 2011 02:02
-
-
Save mecdemort/891691 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 when-lets [bindings & body] | |
(let [[form tst & rest] bindings] | |
(if (seq rest) | |
`(when-let [~form ~tst] (when-lets ~rest ~@body)) | |
`(when-let [~form ~tst] ~@body)))) | |
(defmacro when-lets [bindings & body] | |
(reduce (fn [acc formtst] | |
`(when-let ~(vec formtst) ~acc)) | |
(cons 'do body) | |
(reverse (partition 2 bindings)))) | |
body ,))) | |
(clojure.walk/macroexpand-all | |
'(when-lets [n (first sizes) | |
s (seq coll)] | |
(cons (take n coll) | |
(partitions (next sizes) (drop n coll))))) | |
(when-let [n (first sizes)] | |
(when-let [s (seq coll)] | |
(cons (take n coll) (partitions (next sizes) (drop n coll))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment