Обобщение stream-map
Закончите следующее определение, которое обобщает процедуру stream-map , чтобы она позволяла использовать процедуры от нескольких аргументов, подобно стандартной map языка Scheme. Этот вариант map принимает процедуру от n аргументов и n списков и применяет процедуру ко всем первым элементам списков, всем вторым элементам списков и так далее. Возвращается список результатов. Например:
(map + (list 1 2 3) (list 40 50 60) (list 700 800 900))
(741 852 963)
(map (lambda (x y) (+ x (* 2 y)))
(list 1 2 3)
(list 4 5 6))
(9 12 15)
(define (stream-map proc . argstreams)
(if ( (car argstreams))
the-empty-stream
(
(apply proc (map argstreams))
(apply stream-map
(cons proc (map argstreams))))))
Using procs provided in tests makes implementation of stream-map consistent with the book, but also makes it actually calculate the whole list provided (at the moment when stream-map is applied, NOT when you try to access the resulting stream). It happens because cons-stream will calculate its arguments unlike the original stream-cons from racket library