in lazy.rkt, fix bug in take, where (take 0 non-null-list) was not evaluating to null

This commit is contained in:
Stephen Chang 2011-01-26 15:27:18 -05:00
parent 8cbc701671
commit 39194ba5da

View File

@ -585,7 +585,10 @@
;; to its head, which can lead to memory leaks.
(error 'take "index ~e too large for input list" n0)
'())]
[(pair? l) (cons (car l) (~ (loop (sub1 n) (! (cdr l)))))]
[(pair? l)
(if (zero? n)
'()
(cons (car l) (~ (loop (sub1 n) (! (cdr l))))))]
[else (error 'take "not a proper list: ~e" l)]))
(raise-type-error 'take "non-negative exact integer" 0 n l))))