fix string-ith's error message; Closes PR 13197
This commit is contained in:
parent
b48d122dd7
commit
f733f149f5
|
@ -482,11 +482,11 @@ namespace.
|
|||
|
||||
(define-teach beginner string-ith
|
||||
(lambda (s n)
|
||||
(define f "exact integer in [0, length of the given string]")
|
||||
(cerr 'string-ith (string? s) "string" s "first")
|
||||
(cerr 'string-ith (and (number? n) (integer? n) (>= n 0)) NAT n "second")
|
||||
(let ([l (string-length s)])
|
||||
(cerr 'string-ith (< n l) f n "second"))
|
||||
(define l (string-length s))
|
||||
(define f (format "exact integer in [0, ~a) (i.e., less than the length of the given string)" l))
|
||||
(cerr 'string-ith (< n l) f n "second")
|
||||
(string (string-ref s n))))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
|
|
@ -321,7 +321,7 @@
|
|||
|
||||
(htdp-err/rt-test (string-ith "hell" 4)
|
||||
(exn-type-and-msg exn:fail:contract?
|
||||
"string-ith: expected an exact integer in [0, length of the given string] for the second argument, but received 4"))
|
||||
"string-ith: expected an exact integer in [0, 4) (i.e., less than the length of the given string) for the second argument, but received 4"))
|
||||
|
||||
(htdp-err/rt-test (string-ith 10 4)
|
||||
(exn-type-and-msg exn:fail:contract?
|
||||
|
|
Loading…
Reference in New Issue
Block a user