Functional dict-update.

This commit is contained in:
Dominik Pantůček 2023-04-06 19:21:50 +02:00
parent 00ec081a39
commit 54569ea2e5

View file

@ -37,6 +37,7 @@
dict-map
dict-filter
dict-reduce
dict-update
dictionary-tests!
)
@ -145,6 +146,11 @@
(loop (cdr d)
(proc acc (caar d) (cdar d))))))
;; Functional update
(define (dict-update d k proc . dfls)
(dict-set d k
(proc (apply dict-ref d k dfls))))
;; Performs self-tests of the dictionary module.
(define (dictionary-tests!)
(run-tests