chickadee » srfi-40 » stream-delay

stream-delay expressionprocedure

stream-delay is the essential mechanism for operating on streams, taking an expression and returning a delayed form of the expression that can be asked at some future point to evaluate the expression and return the resulting value. The action of stream-delay is analogous to the action of delay, but it is specific to the stream data type, returning a stream instead of a promise; no corresponding stream-force is required, because each of the stream functions performs the force implicitly.

(define from0
  (let loop ((x 0))
    (stream-delay
      (stream-cons x (loop (+ x 1))))))
from0                                       => (stream 0 1 2 3 4 5 6 ...)