Correct the contract in Example 3 to use and/c.

Closes PR 13486.
This commit is contained in:
Danny Yoo 2013-02-08 14:05:46 -07:00
parent 670efed007
commit c19b8a4f7c
2 changed files with 5 additions and 2 deletions

View File

@ -9,4 +9,7 @@
"dictionaries"
(test-equal? "value for" 2 (value-for d 'b))
(test-false "has?" (has? (rem d 'b) 'b))
(test-equal? "count" 3 (count d))))
(test-equal? "count" 3 (count d))
(test-case "contract check for put: symbol?"
(define d0 (initialize (flat-contract integer?) =))
(check-exn exn:fail:contract? (lambda () (put d0 "a" 2))))))

View File

@ -59,7 +59,7 @@
;; via initialize. We could do the same via a key? parameter
;; (exercise). add key k with value v to this dictionary
[put (->d ([d dictionary?]
[k (and symbol? (not-has? d))]
[k (and/c symbol? (not-has? d))]
[v (dictionary-value? d)])
()
[result dictionary?]