aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2018-07-03 18:15:35 -0400
committerEduardo Julian2018-07-03 18:15:35 -0400
commitbfd2d6c203042dfddb0ce29db3696365fe213314 (patch)
tree19ace3ddccc8237767bc330c471a8f43535aafe2 /stdlib/source
parente828bada4bea51931b0c555a98bc5cd677d52e79 (diff)
- Added function for updating dictionary.
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/data/coll/dictionary/ordered.lux6
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)