Tuple
Encyclopedia : T : TU : TUP : Tuple
- For the musical term, see tuplet.
The name "ordered list" is also used for design tuple.
Names of tuples
The term originated as an abstraction of the sequence: single, double, triple, quadruple, quintuple, n-tuple. A tuple of length n is usually described as an n-tuple. A 2-tuple is called a pair; a 3-tuple is a triple or triplet. The n can be any positive integer; thus one can for example say that a quaternion can be represented as a 4-tuple, and further constructed names are possible, such as octuple, but many mathematicians find it quicker to write "8-tuple", even if still pronouncing "octuple".Names for tuples of specific length
- Single (1) (or singleton or sole or only - many others)
- Double (2) (or pair or twice)
- Triple (3) (or triplet or treble or thrice or threesome or troika or trio)
- Quadruple (4), quintuple or pentuple (5), sextuple or hextuple (6), septuple (7), octuple (8), nonuple (9) and decuple (10).
Formal definitions
The main properties that distinguish a tuple from, for example, a set are that (1) it can contain an object more than once and (2) the objects appear in a certain order. Note that (1) distinguishes it from an ordered set and that (2) distinguishes it from a multiset. This is often formalized by giving the following rule for the identity of two n-tuples:
- (a1, a2, ...,an) = (b1, b2, ..., bn) iff a1 = b1, a2 = b2 and so on.
- (a1, a2, ..., an) = (a1, (a2, ..., an))
- the 0-tuple (i.e. the empty tuple) is represented by ∅
- if x is an n-tuple then
is an (n + 1)-tuple.
(1,(2,(2,()))) = (1,(2, )) = (1, }} ) = }}}}
- a special symbol NIL represents the empty list;
- if X is a list and A an arbitrary value then the pair (A, X) represents a list with the head (i.e. first element) A and the tail (i.e. the remainder of the list without the head) X.
Usage in computer science
In computer science, tuple can have two distinct meanings. Typically in functional and some other programming languages, a tuple is a data object that holds several objects, similar to a mathematical tuple. Such an object is also known as a record.In some languages, and especially in database theory, a tuple is usually defined as a finite function that maps field names to a certain value. Its purpose is the same as in mathematics, namely to indicate that a certain entity or object consists of certain components and/or has certain properties, but here these components are identified by a unique field name and not by a position, which often leads to a more user-friendly notation. The general term for this construct is an associative array; other programming languages have yet other names for the concept.
A small example of a tuple would be:
- ( player : "Harry", score : 25 )
- ( score : 25, player : "Harry" )
In programming, languages tuples are used to form data structures. For example, the following could be a structure that represents a node in a doubly linked list:
- ( value : 16, previous-node : 1174782, next-node : 1174791 )
See also
- Cartesian product
- Formal language
- OLAP: Multidimensional Expressions
- Relation (mathematics)
- Tuple calculus
- Unit type
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
