View Source Antikythera.EnumUtil (antikythera v0.5.1)
Utility functions to work with enumerables.
Summary
Functions
A variant of Enum.find/2
that raises an exception when no matching element is found.
A variant of Enum.find_value/2
that raises an exception when no matching element is found.
Updates items of an enumerable with the given function, depending on context.
Context can be any
.
Types
@type context() :: any()
@type element() :: Enum.element()
Functions
A variant of Enum.find/2
that raises an exception when no matching element is found.
A variant of Enum.find_value/2
that raises an exception when no matching element is found.
@spec map_with_context( Enum.t(), context(), (element(), context() -> {element(), context()}) ) :: [element()]
Updates items of an enumerable with the given function, depending on context.
Context can be any
.
The function fun
takes item and context as arguments, and must achieve 2 purposes:
- Update an item according to current context
- Produces new context for next item
then, return both as tuple {new_item, new_context}
.