original commit: 63f4581f557b5eb20c9aedb37651a06c207c316f
This commit is contained in:
Matthew Flatt 1997-08-18 19:18:29 +00:00
parent 5cdd3f7b60
commit fa767439a0

View File

@ -171,7 +171,10 @@
[(f init l) (fold-one f init l)] [(f init l) (fold-one f init l)]
[(f init l . ls) (fold-n f init (cons l ls))])))) [(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 second (polymorphic cadr))
(define third (polymorphic caddr)) (define third (polymorphic caddr))
(define fourth (polymorphic cadddr)) (define fourth (polymorphic cadddr))
@ -180,8 +183,11 @@
(define seventh (polymorphic (compose fourth cdddr))) (define seventh (polymorphic (compose fourth cdddr)))
(define eighth (polymorphic (compose fourth cddddr))) (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 (define build-string
(lambda (n fcn) (lambda (n fcn)
(unless (and (integer? n) (exact? n) (>= n 0)) (unless (and (integer? n) (exact? n) (>= n 0))