cs: more repairs for old vector-based HAMT
Fix `hash-map` and `hash-for-each` for applicable structs.
This commit is contained in:
parent
58deff8b6f
commit
c7e6cbc001
|
@ -598,6 +598,20 @@
|
|||
(for/sum ([v (in-hash-values new-ht)])
|
||||
v)))
|
||||
|
||||
;; ----------------------------------------
|
||||
;; Make sure hash-table iteration can call an applicable struct
|
||||
|
||||
(let ()
|
||||
(struct proc (f) #:property prop:procedure (struct-field-index f))
|
||||
|
||||
(test '(2) hash-map (hash 'one 1) (proc (lambda (k v) (add1 v))))
|
||||
(test '(2) hash-map (hasheq 'one 1) (proc (lambda (k v) (add1 v))))
|
||||
(test '(2) hash-map (hasheqv 'one 1) (proc (lambda (k v) (add1 v))))
|
||||
|
||||
(test (void) hash-for-each (hash 'one 1) (proc void))
|
||||
(test (void) hash-for-each (hasheq 'one 1) (proc void))
|
||||
(test (void) hash-for-each (hasheqv 'one 1) (proc void)))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -129,10 +129,10 @@
|
|||
(hamt-fold h '() (lambda (_ v xs) (cons v xs))))
|
||||
|
||||
(define (intmap-for-each h proc)
|
||||
(hamt-fold h (void) (lambda (k v _) (proc k v) (void))))
|
||||
(hamt-fold h (void) (lambda (k v _) (|#%app| proc k v) (void))))
|
||||
|
||||
(define (intmap-map h proc)
|
||||
(hamt-fold h '() (lambda (k v xs) (cons (proc k v) xs))))
|
||||
(hamt-fold h '() (lambda (k v xs) (cons (|#%app| proc k v) xs))))
|
||||
|
||||
;; generatic iteration by counting
|
||||
(define (intmap-iterate-first h)
|
||||
|
|
Loading…
Reference in New Issue
Block a user