From e6cd817a65881dfe0076c303ffaa29eaa1b8b916 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 7 Apr 2009 16:28:35 +0000 Subject: [PATCH] fix equal-hash result to be non-negative (PR 10171) svn: r14442 --- collects/rnrs/hashtables-6.ss | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/collects/rnrs/hashtables-6.ss b/collects/rnrs/hashtables-6.ss index 15aa6c88d8..c137e596c8 100644 --- a/collects/rnrs/hashtables-6.ss +++ b/collects/rnrs/hashtables-6.ss @@ -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)))