Functional dict-update.
This commit is contained in:
parent
00ec081a39
commit
54569ea2e5
1 changed files with 6 additions and 0 deletions
|
@ -37,6 +37,7 @@
|
||||||
dict-map
|
dict-map
|
||||||
dict-filter
|
dict-filter
|
||||||
dict-reduce
|
dict-reduce
|
||||||
|
dict-update
|
||||||
dictionary-tests!
|
dictionary-tests!
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -145,6 +146,11 @@
|
||||||
(loop (cdr d)
|
(loop (cdr d)
|
||||||
(proc acc (caar d) (cdar 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.
|
;; Performs self-tests of the dictionary module.
|
||||||
(define (dictionary-tests!)
|
(define (dictionary-tests!)
|
||||||
(run-tests
|
(run-tests
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue