Predicate and collection normalization helpers for collection operations.
Collapses the combinatorial explosion of pred types x collection types into two reusable normalization functions.
Summary
Functions
Convert string to list of graphemes.
Normalize a key/function to a 1-arity value-extracting function.
Normalize a predicate to a 1-arity function.
Normalize any collection to a list. Maps become [k, v] pairs.
Raise a type error for vector used where predicate/function expected.
Functions
Convert string to list of graphemes.
Normalize a key/function to a 1-arity value-extracting function.
Same as normalize_pred/2 with :value mode but with a different
vector error message ("function or key" vs "predicate").
Normalize a predicate to a 1-arity function.
Mode :truthy returns a boolean-coercing function (for filter, remove, find,
every?, not_any?, take_while, drop_while).
Mode :value returns a value-extracting function (for some, keep).
Normalize any collection to a list. Maps become [k, v] pairs.
Raise a type error for vector used where predicate/function expected.