map

added

ns
clojure.core.async

type
function

(map f chs) (map f chs buf-or-n)

Takes a function and a collection of source channels, and returns a
channel which contains the values produced by applying f to the set
of first items taken from each source channel, followed by applying
f to the set of second items from each channel, until any one of the
channels is closed, at which point the output channel will be
closed. The returned channel will be unbuffered by default, or a
buf-or-n can be supplied

                user=> (def cx
         (to-chan
          (range 10)))
#'user/cx

user=> (def cy
         (to-chan
          (range -10 0)))
#'user/cy

user=> (def mapped-chans
         (clojure.core.async/map + [cx cy]))
#'user/mapped-chans

;;
user=> (<!! mapped-chans)
-10
user=> (<!! mapped-chans)
-8
user=> (<!! mapped-chans)
-6
user=> (<!! mapped-chans)
-4
user=> (<!! mapped-chans)
-2
user=> (<!! mapped-chans)
0
user=> (<!! mapped-chans)
2
user=> (<!! mapped-chans)
4
user=> (<!! mapped-chans)
6
user=> (<!! mapped-chans)
8
user=> (<!! mapped-chans)
nil