FunFunc v0.2.0 FunFunc.Tuple
Functions for Tuple. These functions accept a arbitaly length tuple.
Link to this section Summary
Functions
Takes the first value in the tuple
Maps the value in the tuple. The index is zero-index
Maps the first value in the tuple
Maps the value in the tuple. The index is zero-index
Takes the second value in the tuple
Swaps first two elements
Swaps values in the tuple. The index is zero-index
Link to this section Functions
Takes the first value in the tuple.
Examples
iex> FunFunc.Tuple.fst({1, 2})
1
iex> FunFunc.Tuple.fst({1, 2, 3})
1
Maps the value in the tuple. The index is zero-index.
Examples
iex> FunFunc.Tuple.map({1, 2}, 0, &Integer.to_string/1)
{"1", 2}
iex> FunFunc.Tuple.map({1, 2, 3}, 2, &Integer.to_string/1)
{1, 2, "3"}
Maps the first value in the tuple.
Examples
iex> FunFunc.Tuple.map_fst({1, 2}, &Integer.to_string/1)
{"1", 2}
iex> FunFunc.Tuple.map_fst({1, 2, 3}, &Integer.to_string/1)
{"1", 2, 3}
Maps the value in the tuple. The index is zero-index.
Examples
iex> FunFunc.Tuple.map_snd({1, 2}, &Integer.to_string/1)
{1, "2"}
iex> FunFunc.Tuple.map_snd({1, 2, 3}, &Integer.to_string/1)
{1, "2", 3}
Takes the second value in the tuple.
Examples
iex> FunFunc.Tuple.snd({1, 2})
2
iex> FunFunc.Tuple.snd({1, 2, 3})
2
Swaps first two elements.
Examples
iex> FunFunc.Tuple.swap({1, 2})
{2, 1}
iex> FunFunc.Tuple.swap({1, 2, 3})
{2, 1, 3}