Fxnk v0.1.1 Fxnk.List View Source

Fxnk.List are functions for working with lists.

Link to this section Summary

Functions

reduce_right/3 takes a list of args, an initial value and a function and returns a single value.

zip_map/2 is a lot like Enum.zip/2, but instead of returning a list of tuples, it returns a list of maps, where the keys are the second list passed in.

Link to this section Functions

Link to this function

reduce_right(args, initial, func)

View Source

Specs

reduce_right([any()], any(), function()) :: any()

reduce_right/3 takes a list of args, an initial value and a function and returns a single value.

Like reduce, it applies the function to each of the arguments, and accumulating the result, except it does it right to left.

Examples

iex> Fxnk.List.reduce_right([1,2,3,4,5], 0, fn a, b -> a + b end)
15

Specs

zip_map([any()], [any()]) :: [%{required(any()) => any()}]

zip_map/2 is a lot like Enum.zip/2, but instead of returning a list of tuples, it returns a list of maps, where the keys are the second list passed in.

Examples

iex> Fxnk.List.zip_map(["hello", "world"], ["first", "second"])
[%{"first" => "hello"}, %{"second" => "world"}]