Permalink
Browse files

add `stream' which functions analogously to `list'

  • Loading branch information...
1 parent 447bd44 commit 590ff9931391b84789682ee4ed66efa4a7e70b34 @danking danking committed Dec 5, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 collects/racket/stream.rkt
View
@@ -14,6 +14,7 @@
prop:stream
in-stream
+ stream
stream->list
stream-length
stream-ref
@@ -27,7 +28,14 @@
stream-filter
stream-add-between
stream-count)
-
+
+(define-syntax stream
+ (syntax-rules ()
+ ((_)
+ stream-empty)
+ ((_ hd tl ...)
+ (stream-cons hd (stream tl ...)))))
+
(define (stream->list s)
(for/list ([v (in-stream s)]) v))

0 comments on commit 590ff99

Please sign in to comment.