clarify error message for take and drop (#1582)
This commit is contained in:
parent
b978631823
commit
6e746891ef
|
@ -144,16 +144,13 @@
|
||||||
(define (drop* list n) ; no error checking, returns #f if index is too large
|
(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)))))
|
(if (zero? n) list (and (pair? list) (drop* (cdr list) (sub1 n)))))
|
||||||
(define (too-large who list n)
|
(define (too-large who list n)
|
||||||
(raise-arguments-error
|
(define proper? (list? list))
|
||||||
who
|
(raise-argument-error who
|
||||||
(if (list? list)
|
(format "a ~alist with at least ~a ~a"
|
||||||
"index is too large for list"
|
(if proper? "" "(possibly improper) ")
|
||||||
"index reaches a non-pair")
|
n
|
||||||
"index" n
|
(if proper? "elements" "pairs"))
|
||||||
(if (list? list)
|
list))
|
||||||
"list"
|
|
||||||
"in")
|
|
||||||
list))
|
|
||||||
|
|
||||||
(define (take list0 n0)
|
(define (take list0 n0)
|
||||||
(unless (exact-nonnegative-integer? n0)
|
(unless (exact-nonnegative-integer? n0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user