From d65318dd916a3529f009e8c431b8da2df6446c0e Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Thu, 13 Jan 2022 15:47:30 -0800 Subject: Generalize the hash map. Before we were assuming keys could be compared with eqv?. But it seems like that assumption isn't true when we want to hold identifiers in the hash map. --- csc/hash-map-test.csc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'csc/hash-map-test.csc') diff --git a/csc/hash-map-test.csc b/csc/hash-map-test.csc index 353e6b4..3e26570 100644 --- a/csc/hash-map-test.csc +++ b/csc/hash-map-test.csc @@ -15,8 +15,15 @@ (stringstring s1) (symbol->string s2))) +(define (cmp-symbols s1 s2) + (cond + ((symbolmap->alist l) - (map->alist (alist->map hash-symbol symbolalist (alist->map hash-symbol cmp-symbols l))) (define (sort-alist l) @@ -70,9 +77,9 @@ (test lookup (assert-equal 2 - (lookup (alist->map hash-symbol symbolmap hash-symbol cmp-symbols '((a . 1) (b . 2) (c . 3))) 'b))) (test lookup-notfound (assert-raises key-not-found-error? - (lookup (alist->map hash-symbol symbolmap hash-symbol cmp-symbols '((a . 1) (b . 2) (c . 3))) 'd))) -- cgit v1.3.1