Fix the definition of head and tail to check for a proper stream.
authorGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Wed, 10 May 1989 08:51:11 +0000 (08:51 +0000)
committerGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Wed, 10 May 1989 08:51:11 +0000 (08:51 +0000)
v7/src/runtime/stream.scm

index 6d2f8600c4475684cca7b6d7df8f8818b14705ba..dac91c94bb7bccd9f587367af21842310022a9ff 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/stream.scm,v 14.2 1988/12/30 06:43:22 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/stream.scm,v 14.3 1989/05/10 08:51:11 jinx Rel $
 
 Copyright (c) 1988 Massachusetts Institute of Technology
 
@@ -115,11 +115,15 @@ MIT in each case. |#
 (define-integrable (empty-stream? stream)
   (stream-null? stream))
 
-(define-integrable (head stream)
-  (stream-car stream))
+(define (head stream)
+  (if (stream-pair? stream)
+      (stream-car stream)
+      (error "head: not a proper stream" stream)))
 
-(define-integrable (tail stream)
-  (stream-cdr stream))
+(define (tail stream)
+  (if (stream-pair? stream)
+      (stream-cdr stream)
+      (error "tail: not a proper stream" stream)))
 
 (define prime-numbers-stream)