fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Idiom # 140: Delete map entry

See programming-idioms.org:

Code

remove deletes the entry with key k from map m and returns the removed value as an option. If k is missing, the result is nil and m remains unchanged. Since Fuzion requires all results to be used, you must assign the result to _ to ignore it.

Mutable and immutable maps

Fuzion distinguishes between immutable maps (container.Map, e.g., container.ps_map) and mutable maps (container.Mutable_Map). An immutable map cannot be changed, so it provides no remove. Entries can only be removed from a mutable map. Fuzion provides two mutable implementations:

  • container.Mutable_Hash_Map - a fast hash table with an undefined key order.
  • container.Mutable_Tree_Map - a tree that keeps keys sorted, with O(log n) operations.

Mutable data in Fuzion requires a mutate effect. It is passed as the first type parameter of the map. Here is local mutate effect lm used:

Runnable Example

This example uses container.Mutable_Tree_Map to print the remaining entries in sorted order. To use a hash map instead, replace it with container.Mutable_Hash_Map.

last changed: 2026-10-14