Skip to content

Instantly share code, notes, and snippets.

@ijp
Created February 6, 2012 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ijp/1751461 to your computer and use it in GitHub Desktop.
Save ijp/1751461 to your computer and use it in GitHub Desktop.
;; will work for any sufficiently lazy functor ;-)
(letrec ((loeb (lambda (stream)
(define (%loeb stream)
(delay
(stream-map (lambda (func)
(func (force (%loeb stream))))
stream)))
(force (%loeb stream))))
(s (stream stream-length
stream-car
(cut stream-ref <> 3)
(cut stream-ref <> 1))))
(stream->list (loeb s)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment