From bfd2d6c203042dfddb0ce29db3696365fe213314 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 3 Jul 2018 18:15:35 -0400 Subject: - Added function for updating dictionary. --- stdlib/source/lux/data/coll/dictionary/ordered.lux | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'stdlib/source') 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 + [old (get key dict)] + (wrap (put key (transform old) dict)))) + (def: #export (from-list Order list) (All [k v] (-> (Order k) (List [k v]) (Dict k v))) (L/fold (function (_ [key value] dict) -- cgit v1.2.3