clarify error message for take and drop (#1582)

This commit is contained in:
Benjamin Greenman 2017-03-06 18:45:09 -05:00 committed by GitHub
parent b978631823
commit 6e746891ef

View File

@ -144,16 +144,13 @@
(define (drop* list n) ; no error checking, returns #f if index is too large
(if (zero? n) list (and (pair? list) (drop* (cdr list) (sub1 n)))))
(define (too-large who list n)
(raise-arguments-error
who
(if (list? list)
"index is too large for list"
"index reaches a non-pair")
"index" n
(if (list? list)
"list"
"in")
list))
(define proper? (list? list))
(raise-argument-error who
(format "a ~alist with at least ~a ~a"
(if proper? "" "(possibly improper) ")
n
(if proper? "elements" "pairs"))
list))
(define (take list0 n0)
(unless (exact-nonnegative-integer? n0)