diff --git a/src/dictionary.scm b/src/dictionary.scm index 966ba61..164776a 100644 --- a/src/dictionary.scm +++ b/src/dictionary.scm @@ -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