The execution of the function itself can be performed on one line:
(define (stream-from ns) (stream-cons n (stream-from (+ ns) s)))
To test this, you are here an example that prints 100,000 numbers:
#lang racket (require racket/stream) (define (stream-from ns) (stream-cons n (stream-from (+ ns) s))) (define (stream-while sp) (let ([fst (stream-first s)]) (if (p fst) (stream-cons fst (stream-while (stream-rest s) p)) empty-stream))) (define test (stream-while (stream-from 0 1) (Ξ» (x) (< x 100000)))) (stream-for-each println test)
source share