fix equal-hash result to be non-negative (PR 10171)

svn: r14442
This commit is contained in:
Matthew Flatt 2009-04-07 16:28:35 +00:00
parent 6fecf78da0
commit e6cd817a65

View File

@ -19,7 +19,7 @@
hashtable-equivalence-function
hashtable-hash-function
hashtable-mutable?
(rename-out [equal-hash-code equal-hash])
equal-hash
string-hash
string-ci-hash
symbol-hash)
@ -143,17 +143,20 @@
(values (list->vector (map (lambda (p) (unwrap (car p))) ps))
(list->vector (map cdr ps)))))
(define (equal-hash v)
(abs (equal-hash-code v)))
(define (string-hash s)
(unless (string? s)
(raise-type-error 'string-hash "string" s))
(equal-hash-code s))
(abs (equal-hash-code s)))
(define (string-ci-hash s)
(unless (string? s)
(raise-type-error 'string-ci-hash "string" s))
(equal-hash-code (string-foldcase s)))
(abs (equal-hash-code (string-foldcase s))))
(define (symbol-hash s)
(unless (symbol? s)
(raise-type-error 'symbol-hash "symbol" s))
(eq-hash-code s))
(abs (eq-hash-code s)))