From c04e3c7cd6726a95da3d58979f582afb7a5b722f Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 24 Jul 2022 16:20:00 -0700 Subject: Export some common comparers from hash-map. --- csc/hash-map-test.csc | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'csc/hash-map-test.csc') diff --git a/csc/hash-map-test.csc b/csc/hash-map-test.csc index 7885908..da58e69 100644 --- a/csc/hash-map-test.csc +++ b/csc/hash-map-test.csc @@ -12,19 +12,8 @@ (csc hash-map)) -(define (hash-symbol s) - (hash-bytevector (string->utf8 (symbol->string s)))) - - -(define (cmp-symbols s1 s2) - (cond - ((symbol=? s1 s2) 0) - ((stringstring s1) (symbol->string s2)) -1) - (else 1))) - - (define (alist->map->alist l) - (map->alist (alist->map hash-symbol cmp-symbols l))) + (map->alist (alist->map compare-symbols l))) (test map->alist-singleton @@ -78,18 +67,18 @@ (test lookup (assert-equal 2 - (lookup (alist->map hash-symbol cmp-symbols '((a . 1) (b . 2) (c . 3))) 'b))) + (lookup (alist->map compare-symbols '((a . 1) (b . 2) (c . 3))) 'b))) (test lookup-notfound (assert-raises key-not-found-error? - (lookup (alist->map hash-symbol cmp-symbols '((a . 1) (b . 2) (c . 3))) 'd))) + (lookup (alist->map compare-symbols '((a . 1) (b . 2) (c . 3))) 'd))) (test lookup-default (assert-equal #f - (lookup (alist->map hash-symbol cmp-symbols '((a . #t) (b . #t))) 'c #f))) + (lookup (alist->map compare-symbols '((a . #t) (b . #t))) 'c #f))) (define transform-map @@ -98,7 +87,7 @@ (define (test-map . bindings) - (alist->map hash-symbol cmp-symbols bindings)) + (alist->map compare-symbols bindings)) (test merge -- cgit v1.3.1