Dicts
Module dicts
import dicts
| Module | dicts |
| Source | dicts/dicts.zirr, dicts/module-docs.zirr |
Operations over
Dict, by key, by value, or by pair.
dicts operates on the built-in prelude.Dict type and returns new dictionaries rather than changing the one passed in.
Iterating a Dict yields prelude.Pair values, which is why mapPairs exists alongside mapKeys and mapValues: it is the one that can change both halves of an entry at once.
Contents
Functions
filter
`dicts/dicts.zirr:56`
fn filter(d: Dict, predicate: fn(Any, Any) -> Bool) -> Dict
Returns a new dict containing only the entries of d for which predicate returns true. predicate receives both the key and its value.
hasKey
`dicts/dicts.zirr:9`
fn hasKey(d: Dict, key: Any) -> Bool
Returns whether d has an entry for key. Indexing alone cannot tell, since a missing key and a void value both read as void.
isEmpty
`dicts/dicts.zirr:4`
fn isEmpty(d: Dict) -> Bool
Returns whether d has no entries.
map
`dicts/dicts.zirr:19`
fn map(d: Dict, transform: fn(Any, Any) -> Any) -> Dict
Returns a new dict with transform applied to each value, keeping the same keys. transform receives both the key and its value.
mapKeys
`dicts/dicts.zirr:28`
fn mapKeys(d: Dict, transform: fn(Any) -> Any) -> Dict
Returns a new dict with transform applied to each key, keeping the same values.
mapPairs
`dicts/dicts.zirr:46`
fn mapPairs(d: Dict, transform: fn(Pair) -> Pair) -> Dict
Returns a new dict with transform applied to each key/value Pair, replacing both.
mapValues
`dicts/dicts.zirr:37`
fn mapValues(d: Dict, transform: fn(Any) -> Any) -> Dict
Returns a new dict with transform applied to each value, keeping the same keys.
reduce
`dicts/dicts.zirr:67`
fn reduce(d: Dict, initial: Any, combine: fn(Any, Any, Any) -> Any) -> Any
Combines d’s entries into a single value, starting from initial and applying combine(accumulator, key, value) for each entry, in no particular order.