diff options
author | Eduardo Julian | 2018-07-03 18:15:35 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-07-03 18:15:35 -0400 |
commit | bfd2d6c203042dfddb0ce29db3696365fe213314 (patch) | |
tree | 19ace3ddccc8237767bc330c471a8f43535aafe2 /stdlib | |
parent | e828bada4bea51931b0c555a98bc5cd677d52e79 (diff) |
- Added function for updating dictionary.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/coll/dictionary/ordered.lux | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/stdlib/source/lux/data/coll/dictionary/ordered.lux b/stdlib/source/lux/data/coll/dictionary/ordered.lux index 16412e648..aec44d943 100644 --- a/stdlib/source/lux/data/coll/dictionary/ordered.lux +++ b/stdlib/source/lux/data/coll/dictionary/ordered.lux @@ -519,6 +519,12 @@ (set@ #root (#.Some (blacken root)) dict) ))) +(def: #export (update key transform dict) + (All [k v] (-> k (-> v v) (Dict k v) (Maybe (Dict k v)))) + (do maybe.Monad<Maybe> + [old (get key dict)] + (wrap (put key (transform old) dict)))) + (def: #export (from-list Order<l> list) (All [k v] (-> (Order k) (List [k v]) (Dict k v))) (L/fold (function (_ [key value] dict) |