chickadee » srfi-127 » lseq-map

lseq-map proc lseq1 lseq2 ...procedure

The lseq-map procedure lazily applies proc element-wise to the corresponding elements of the lseqs, where proc is a procedure taking as many arguments as there are lseqs and returning a single value, and returns an lseq of the results in order. The dynamic order in which proc is applied to the elements of the lseqs is unspecified.

(lseq-map
 (lambda (x) (lseq-car (lseq-cdr x)))
 '((a b) (d e) (g h)))
 ;=>  (b e h)

(lseq-map (lambda (n) (expt n n))
 (make-iota-generator +inf.0 1 1)
 ;=> (1 4 27 256 3125 ...)

 (lseq-map + '(1 2 3) '(4 5 6)) =>  (5 7 9)

 (let ((count 0))
  (lseq-map (lambda (ignored)
             (set! count (+ count 1))
             count)
   '(a b)))
 ;=>  (1 2) or (2 1)