diff --git a/lib/std/data/sorted-dict.kk b/lib/std/data/sorted-dict.kk index d88e4a4ee..fcffeddc3 100644 --- a/lib/std/data/sorted-dict.kk +++ b/lib/std/data/sorted-dict.kk @@ -40,13 +40,19 @@ public fun empty(compare: (k, k) -> order): sorted-dict { Sorted-dict(from-compare(compare), empty) } -public fun get(dict: sorted-dict, key: k): maybe { +public fun [](dict: sorted-dict, key: k): maybe { unsafe-lookup(dict.tree, key, dict.compare).map(snd) } +// TODO inline this +// TODO maybe it shouldn't include this ? +public fun [](dict: sorted-dict, key: k, value: a): sorted-dict { + set(dict, key, value) +} + public fun has?(dict: sorted-dict, key: k): bool { // TODO this can be implemented faster - bool(get(dict, key)) + bool(dict[key]) } public fun set(dict: sorted-dict, key: k, value: a): sorted-dict {