Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; I'm not sure e.g.
  2. ;; (mapf (cycle f1 f2 f3) collection)
  3. ;; is a big improvement over
  4. ;; (map #(%1 %2) (cycle f1 f2 f3) collection)
  5. ;;
  6. ;; In theory, this would have to be further generalized to any number of
  7. ;; collections (a la map).
  8. (defn mapf [fs coll]
  9.   (lazy-seq
  10.    (when-let [fns (seq fs)
  11.               s (seq coll)]
  12.      (cons ((first fns) (first s)) (mapf (rest fns) (rest s))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement