func v0.4.1 Func.Tuple

Summary

Functions

Takes the first element of Pair

Maps the first element, then returns the pair

Maps the second element, then returns the pair

Takes the second element of pair

Swaps elements of pair

Functions

fst(pair)
fst({any, any}) :: any

Takes the first element of Pair.

iex> Func.Tuple.fst({1, 2})
1
map_fst(pair, func)
map_fst({any, any}, (... -> any)) :: {any, any}

Maps the first element, then returns the pair.

iex> Func.Tuple.map_fst({1, 2}, &Integer.to_string/1)
{"1", 2}
map_snd(pair, func)
map_snd({any, any}, (... -> any)) :: {any, any}

Maps the second element, then returns the pair.

iex> Func.Tuple.map_snd({1, 2}, &Integer.to_string/1)
{1, "2"}
snd(pair)
snd({any, any}) :: any

Takes the second element of pair.

iex> Func.Tuple.snd({1, 2})
2
swap(pair)
swap({any, any}) :: {any, any}

Swaps elements of pair.

iex> Func.Tuple.swap({1, 2})
{2, 1}