Module shards_enum

Provides a set of utilities to work with enumerables.

Description

Provides a set of utilities to work with enumerables.

Function Index

map/2 Returns a list where each element is the result of invoking Fun on each corresponding element of Enumerable.
pmap/2Equivalent to pmap(Fun, infinity, Enumerable).
pmap/3 Similar to shards_enum:map/2 but it runs in parallel.
reduce/3 Invokes Fun for each element in the Enumerable with the accumulator.
reduce_while/3 Reduces enumerable until Fun returns {halt, AccOut}.

Function Details

map/2

map(Fun, Enumerable) -> [Result]

Returns a list where each element is the result of invoking Fun on each corresponding element of Enumerable.

For maps, the function expects a key-value tuple.

pmap/2

pmap(Fun, Enumerable) -> any()

Equivalent to pmap(Fun, infinity, Enumerable).

pmap/3

pmap(Fun, Timeout, Enumerable) -> [Result]

Similar to shards_enum:map/2 but it runs in parallel.

reduce/3

reduce(Fun, Acc0, Enumerable) -> Acc1

Invokes Fun for each element in the Enumerable with the accumulator.

The initial value of the accumulator is Acc0. The function is invoked for each element in the enumerable with the accumulator. The result returned by the function is used as the accumulator for the next iteration. The function returns the last accumulator.

reduce_while/3

reduce_while(Fun, Acc0, Enumerable) -> Acc1

Reduces enumerable until Fun returns {halt, AccOut}.

The return value for Fun is expected to be

If fun returns {halt, AccOut} the reduction is halted and the function returns AccOut. Otherwise, if the enumerable is exhausted, the function returns the accumulator of the last {cont, AccOut}.


Generated by EDoc