Home

twotuple

Twotuple, also called a 2-tuple or an ordered pair, is a mathematical object consisting of two components arranged in a specific order. It is the simplest nontrivial n-tuple; the first component is distinguished from the second, so (a,b) generally differs from (b,a). A twotuple can be viewed as an element of the Cartesian product A × B, where a ∈ A and b ∈ B.

Formally, an n-tuple of elements from a set X is a function f from the index set

Examples: (3,5) is a 2-tuple whose first component is 3 and second is 5; (x,y) is an

Relation to programming: many languages provide 2-tuple or pair types to group two values; these are used

{1,…,n}
to
X.
A
2-tuple
is
thus
a
function
f:
{1,2}
→
X
with
f(1)=a
and
f(2)=b.
In
set-theoretic
practice,
various
encodings
exist;
for
instance,
the
Kuratowski
definition
represents
an
ordered
pair
by
nested
sets.
In
everyday
mathematics,
(a,b)
is
taken
as
the
primitive
notation
for
the
ordered
pair.
arbitrary
2-tuple.
for
returning
two
values
from
a
function,
storing
coordinates,
or
as
keys
in
data
structures.
Depending
on
the
language,
pairs
may
be
mutable
or
immutable,
and
they
often
support
projection
operations
such
as
first/second
(fst/snd)
or
head/tail
equivalents.
The
2-tuple
is
the
product
of
two
types
in
type
theory,
and
is
a
basic
instance
of
the
Cartesian
product
A
×
B;
many
algebraic
constructions
study
properties
of
product
types
via
projections.