(map f)
(map f coll)
(map f c1 c2)
(map f c1 c2 c3)
(map f c1 c2 c3 & colls)
Returns a lazy sequence consisting of the result of applying f to
the set of first items of each coll, followed by applying f to the
set of second items in each coll, until any one of the colls is
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments. Returns a transducer when
no collection is provided.
Source
(defn
map
"Returns a lazy sequence consisting of the result of applying f to\n the set of first items of each coll, followed by applying f to the\n set of second items in each coll, until any one of the colls is\n exhausted. Any remaining items in other colls are ignored. Function\n f should accept number-of-colls arguments. Returns a transducer when\n no collection is provided."
([f]
(fn
[rf]
(fn
([] (rf))
([result] (rf result))
([result input] (rf result (f input)))
([result input & inputs] (rf result (apply f input inputs))))))
([f coll]
(lazy-seq
(when-let
[s (seq coll)]
(if
(chunked-seq? s)
(let
[c (chunk-first s) size (count c) b (chunk-buffer size)]
(dotimes [i size] (chunk-append b (f (-nth c i))))
(chunk-cons (chunk b) (map f (chunk-rest s))))
(cons (f (first s)) (map f (rest s)))))))
([f c1 c2]
(lazy-seq
(let
[s1 (seq c1) s2 (seq c2)]
(when
(and s1 s2)
(cons (f (first s1) (first s2)) (map f (rest s1) (rest s2)))))))
([f c1 c2 c3]
(lazy-seq
(let
[s1 (seq c1) s2 (seq c2) s3 (seq c3)]
(when
(and s1 s2 s3)
(cons
(f (first s1) (first s2) (first s3))
(map f (rest s1) (rest s2) (rest s3)))))))
([f c1 c2 c3 & colls]
(let
[step
(fn
step
[cs]
(lazy-seq
(let
[ss (map seq cs)]
(when
(every? identity ss)
(cons (map first ss) (step (map rest ss)))))))]
(map
(fn* [p1__18661#] (apply f p1__18661#))
(step (conj colls c3 c2 c1))))))