Elixir v1.0.5 Tuple

Functions for working with tuples.

Summary

Functions

Removes an element from a tuple

Creates a new tuple

Inserts an element into a tuple

Converts a tuple to a list

Functions

delete_at(tuple, index)

Specs

delete_at(tuple, non_neg_integer) :: tuple

Removes an element from a tuple.

Deletes the element at the zero-based index from tuple. Raises an ArgumentError if index is greater than or equal to the length of tuple.

Inlined by the compiler.

Examples

iex> tuple = {:foo, :bar, :baz}
iex> Tuple.delete_at(tuple, 0)
{:bar, :baz}
duplicate(data, size)

Specs

duplicate(term, non_neg_integer) :: tuple

Creates a new tuple.

Creates a tuple of size size containing the given data at every position.

Inlined by the compiler.

Examples

iex> Tuple.duplicate(:hello, 3)
{:hello, :hello, :hello}
insert_at(tuple, index, term)

Specs

insert_at(tuple, non_neg_integer, term) :: tuple

Inserts an element into a tuple.

Inserts value into tuple at the given zero-based index. Raises an ArgumentError if index is greater than the length of tuple.

Inlined by the compiler.

Examples

iex> tuple = {:bar, :baz}
iex> Tuple.insert_at(tuple, 0, :foo)
{:foo, :bar, :baz}
to_list(tuple)

Specs

to_list(tuple) :: list

Converts a tuple to a list.

Inlined by the compiler.