aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map_dict.gleam8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/map_dict.gleam b/src/map_dict.gleam
index 6033866..c25378f 100644
--- a/src/map_dict.gleam
+++ b/src/map_dict.gleam
@@ -86,3 +86,11 @@ pub fn update(dict, key, f) {
| Error(_) -> put(dict, key, f(Error(NotFound)))
}
}
+
+pub fn fold(dict, acc, f) {
+ let kvs = to_list(dict)
+ case kvs {
+ | [] -> acc
+ | [{k, v} | _] -> fold(delete(dict, k), f(k, v, acc), f)
+ }
+}