Exercise 3.50.
map の stream 版である stream-map を作るという穴埋め問題。
(define (stream-map proc . argstreams) (if (stream-null? (car argstreams)) the-empty-stream (cons-stream (apply proc (map car argstreams)) (apply stream-map (cons proc (map cdr argstreams))))))
でいいのかな。任意個の引数はドットの後に書いた変数にリストとして渡ってくるってことか。
(apply stream-map (cons proc (map cdr argstreams)))
が一瞬意味分からなかった。なんで proc と (map cdr argstreams) を cons してなんの意味があるの?と思ったけど、落ち着いて考えてみたら、stream-map へ渡す引数として apply に渡すためにリストにしただけだった。