Created
March 28, 2011 13:48
-
-
Save mecdemort/890483 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
(defn map-all | |
"Sequence of results from applying f to the first of each of colls. | |
Empty colls are dropped and evaluation proceeds." | |
[f & colls] | |
(lazy-seq | |
(when-let [s (seq colls)] | |
(cons (apply f (map first colls)) | |
(apply map-all f (for [coll (map rest s) | |
:when (seq coll)] | |
coll)))))) | |
user> (map-all vector [1 2 3] [4 5] [6]) | |
([1 4 6] [2 5] [3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment