From fa767439a08e9641968b3529eb8302e62bf94874 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 18 Aug 1997 19:18:29 +0000 Subject: [PATCH] release original commit: 63f4581f557b5eb20c9aedb37651a06c207c316f --- collects/mzlib/functior.ss | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/collects/mzlib/functior.ss b/collects/mzlib/functior.ss index 003fe1a..26b8eff 100644 --- a/collects/mzlib/functior.ss +++ b/collects/mzlib/functior.ss @@ -171,7 +171,10 @@ [(f init l) (fold-one f init l)] [(f init l . ls) (fold-n f init (cons l ls))])))) - (define first (polymorphic (lambda (x) (car x)))) + (define first (polymorphic (lambda (x) + (unless (pair? x) + (raise-type-error 'first "list" x)) + (car x)))) (define second (polymorphic cadr)) (define third (polymorphic caddr)) (define fourth (polymorphic cadddr)) @@ -180,8 +183,11 @@ (define seventh (polymorphic (compose fourth cdddr))) (define eighth (polymorphic (compose fourth cddddr))) - (define rest (polymorphic (lambda (x) (cdr x)))) - + (define rest (polymorphic (lambda (x) + (unless (pair? x) + (raise-type-error 'rest "list" x)) + (cdr x)))) + (define build-string (lambda (n fcn) (unless (and (integer? n) (exact? n) (>= n 0))