chickadee » sicp » stream-ref

stream-ref s nprocedure

Returns the nth element of the stream, consuming any non-memoized elements.

s
The stream to consume
n
The nth element
(define (stream-ref s n)
  (if (= n 0) (stream-car s) (stream-ref (stream-cdr s) (- n 1))))