[racket-dev] Need a clarification on the implementation of stream-map

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Jul 9 10:57:17 EDT 2012

On Jul 8, 2012, at 7:25 AM, Daniel King wrote:

>  (define (stream-map f s)
>    (unless (procedure? f) (raise-argument-error 'stream-map "procedure?" f))
>    (unless (stream? s) (raise-argument-error 'stream-map "stream?" s))



On a related note, the above kind of checks should really become real contracts.  -- Matthias





>    (let loop ([s s])
>      (cond
>       [(stream-empty? s) empty-stream]
>       [else (stream-cons (call-with-values (lambda () (stream-first s)) f)
>                          (loop (stream-rest s)))])))






Posted on the dev mailing list.