Home

Tuple

A tuple is an ordered, finite collection of elements, called components or coordinates, with a fixed length n, where n is a nonnegative integer. An n-tuple is typically written as (a1, a2, ..., an) and is an element of the Cartesian product A1 × A2 × ... × An. The order of elements matters, and two n-tuples are equal if and only if their corresponding components are equal. The 0-tuple, denoted (), is the unique tuple of length zero. In mathematics and computer science, tuples can contain elements of different types.

In computing, a tuple is a finite, ordered collection that is usually immutable and used to group

Beyond programming, the term also appears in databases (a row in a relation) and geometry (a point’s

related
values.
Unlike
lists,
tuples
generally
do
not
support
in-place
modification
after
creation.
They
enable
heterogeneous
data,
such
as
(name,
age,
active).
Languages
vary
in
syntax
and
semantics:
Python
uses
parentheses
and
comma
separation
to
create
tuples;
many
languages
treat
a
2-tuple
as
a
pair;
tuples
may
be
nested
and
their
element
types
can
be
fixed
or
dynamic.
Tuples
often
serve
as
lightweight
records
and,
if
all
elements
are
hashable,
can
be
used
as
keys
in
associative
structures.
coordinates
in
n-dimensional
space).
The
arity
of
a
tuple
is
the
number
of
components
it
contains.
In
some
contexts,
a
1-tuple
is
equivalent
to
the
element
itself,
which
leads
to
differing
conventions.
The
notion
of
tuples
underpins
many
formal
constructions,
including
function
arguments
and
product
types.