Elixir v1.3.3 Tuple View Source
Functions for working with tuples.
See also Kernel.elem/2
, Kernel.is_tuple/1
,
Kernel.put_elem/3
, and Kernel.tuple_size/1
.
Link to this section Summary
Functions
Inserts an element at the end of a tuple
Removes an element from a tuple
Creates a new tuple
Inserts an element into a tuple
Converts a tuple to a list
Link to this section Functions
Inserts an element at the end of a tuple.
Returns a new tuple with the element appended at the end, and contains
the elements in tuple
followed by value
as the last element.
Inlined by the compiler.
Examples
iex> tuple = {:foo, :bar}
iex> Tuple.append(tuple, :baz)
{:foo, :bar, :baz}
delete_at(tuple, non_neg_integer) :: tuple
Removes an element from a tuple.
Deletes the element at the given index
from tuple
.
Raises an ArgumentError
if index
is negative or greater than
or equal to the length of tuple
. Index is zero-based.
Inlined by the compiler.
Examples
iex> tuple = {:foo, :bar, :baz}
iex> Tuple.delete_at(tuple, 0)
{:bar, :baz}
Creates a new tuple.
Creates a tuple of size
containing the
given data
at every position.
Inlined by the compiler.
Examples
iex> Tuple.duplicate(:hello, 3)
{:hello, :hello, :hello}
insert_at(tuple, non_neg_integer, term) :: tuple
Inserts an element into a tuple.
Inserts value
into tuple
at the given index
.
Raises an ArgumentError
if index
is negative or greater than the
length of tuple
. Index is zero-based.
Inlined by the compiler.
Examples
iex> tuple = {:bar, :baz}
iex> Tuple.insert_at(tuple, 0, :foo)
{:foo, :bar, :baz}
iex> Tuple.insert_at(tuple, 2, :bong)
{:bar, :baz, :bong}