Expand description
Map operations for Seq
Dictionary/hash map operations with O(1) lookup. Maps use hashable keys (Int, String, Bool) and can store any Value.
§Examples
# Create empty map and add entries
make-map "name" "Alice" map-set "age" 30 map-set
# Get value by key
my-map "name" map-get # -> "Alice"
# Check if key exists
my-map "email" map-has? # -> 0 (false)
# Get keys/values as lists
my-map map-keys # -> ["name", "age"]
my-map map-values # -> ["Alice", 30]§Panic Behavior
- Operations panic on invalid key types (Float, Variant, Quotation, etc.)
map-getpanics if key not found (usemap-get-safefor error handling)- Type errors (e.g., calling map operations on non-Map values) cause panics
§Performance Notes
- Operations use functional style:
map-setandmap-removereturn new maps - Each mutation clones the underlying HashMap (O(n) for n entries)
- For small maps (<100 entries), this is typically fast enough
- Key/value iteration order is not guaranteed (HashMap iteration order)
Re-exports§
pub use patch_seq_make_map as make_map;pub use patch_seq_map_empty as map_empty;pub use patch_seq_map_get as map_get;pub use patch_seq_map_get_safe as map_get_safe;pub use patch_seq_map_has as map_has;pub use patch_seq_map_keys as map_keys;pub use patch_seq_map_remove as map_remove;pub use patch_seq_map_set as map_set;pub use patch_seq_map_size as map_size;pub use patch_seq_map_values as map_values;
Functions§
- patch_
seq_ ⚠make_ map - Create an empty map
- patch_
seq_ ⚠map_ empty - Check if the map is empty
- patch_
seq_ ⚠map_ get - Get a value from the map by key
- patch_
seq_ ⚠map_ get_ safe - Get a value from the map by key, with error handling
- patch_
seq_ ⚠map_ has - Check if a key exists in the map
- patch_
seq_ ⚠map_ keys - Get all keys from the map as a list
- patch_
seq_ ⚠map_ remove - Remove a key from the map (functional style)
- patch_
seq_ ⚠map_ set - Set a key-value pair in the map (functional style)
- patch_
seq_ ⚠map_ size - Get the number of entries in the map
- patch_
seq_ ⚠map_ values - Get all values from the map as a list