Last active
November 24, 2016 17:51
-
-
Save rauhs/52d11ec6e7521030fbf86ed06aaec4db to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| "Like map but if given multiple collections will call the function f | |
| with as many arguments as there are elements still left." | |
| ([f] (map f)) | |
| ([f coll] (map f coll)) | |
| ([f c1 & colls] | |
| (let [step (fn step [cs] | |
| (lazy-seq | |
| (let [ss (keep seq cs)] | |
| (when (seq ss) | |
| (cons (map first ss) | |
| (step (map rest ss)))))))] | |
| (map #(apply f %) (step (conj colls c1)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment