summaryrefslogtreecommitdiffstats
path: root/srfi/srfi-126-impl.scm
diff options
context:
space:
mode:
authorGravatar John Cowan 2022-06-29 08:23:48 -0400
committerGravatar GitHub 2022-06-29 08:23:48 -0400
commitd00d1b8d8f2ee3e19b60357d0d751e818e41745e (patch)
tree812bd300d7b9ece3f690365fb6ce76cabf5040dc /srfi/srfi-126-impl.scm
parenteditorial (diff)
parentupdate implementation (diff)
Merge pull request #4 from arvyy/master
update implementation
Diffstat (limited to 'srfi/srfi-126-impl.scm')
-rw-r--r--srfi/srfi-126-impl.scm32
1 files changed, 21 insertions, 11 deletions
diff --git a/srfi/srfi-126-impl.scm b/srfi/srfi-126-impl.scm
index b4c9845..4bdb53d 100644
--- a/srfi/srfi-126-impl.scm
+++ b/srfi/srfi-126-impl.scm
@@ -23,50 +23,60 @@
#t
(begin
(t126-hashtable-set! table (car obj) (cadr obj))
- (loop (cddr obj))))))
+ (loop (cddr obj)))))
+ table)
(define (t126-hashtable-delete-all* dto table keys)
(for-each
(lambda (key)
(t126-hashtable-delete! table key))
- keys))
+ keys)
+ table)
(define (t126-hashtable-intern* dto table key default)
- (t126-hashtable-intern! table key default))
+ (values table (t126-hashtable-intern! table key default)))
(define (t126-hashtable-update/default* dto table key updater default)
- (t126-hashtable-update! table key updater default))
+ (t126-hashtable-update! table key updater default)
+ table)
(define (t126-hashtable-pop* dto table)
(if (t126-hashtable-empty? table)
(error "popped empty dictionary")
- (t126-hashtable-pop! table)))
+ (call-with-values (lambda () (t126-hashtable-pop! table))
+ (lambda (key value) (values table key value)))))
(define (t126-hashtable-update-all* dto proc table)
- (t126-hashtable-update-all! table proc))
+ (t126-hashtable-update-all! table proc)
+ table)
(define (t126-hashtable-filter* dto proc table)
(t126-hashtable-prune! table
(lambda (key value)
- (not (proc key value)))))
+ (not (proc key value))))
+ table)
(define (t126-hashtable-remove* dto proc table)
- (t126-hashtable-prune! table proc))
+ (t126-hashtable-prune! table proc)
+ table)
(define (t126-hashtable-find-update* dto table key fail success)
(define (handle-success value)
(define (update new-key new-value)
(unless (eq? new-key key)
(t126-hashtable-delete! table key))
- (t126-hashtable-set! table new-key new-value))
+ (t126-hashtable-set! table new-key new-value)
+ table)
(define (remove)
- (t126-hashtable-delete! table key))
+ (t126-hashtable-delete! table key)
+ table)
(success key value update remove))
(define (handle-fail)
(define (ignore)
table)
(define (insert value)
- (t126-hashtable-set! table key value))
+ (t126-hashtable-set! table key value)
+ table)
(fail insert ignore))
(define default (cons #f #f))