From c4745062add099913b99915b1be1f70e9f5d26a8 Mon Sep 17 00:00:00 2001 From: "Guillermo J. Rozas" Date: Wed, 10 May 1989 08:51:11 +0000 Subject: [PATCH] Fix the definition of head and tail to check for a proper stream. --- v7/src/runtime/stream.scm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/v7/src/runtime/stream.scm b/v7/src/runtime/stream.scm index 6d2f8600c..dac91c94b 100644 --- a/v7/src/runtime/stream.scm +++ b/v7/src/runtime/stream.scm @@ -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) -- 2.25.1