A tuple is an ordered set of fixed length.
Content
In Math
Let sets be given not necessarily different.
Then a tuple of length n [1] [2] , an ordered set of length n [1] , an ordered n- set [2] or n- ka [1] [3] is an ordered sequence of n elements Where for A tuple is indicated by listing the coordinates in angle or parentheses [1] :
or
Element is called the i- th coordinate [1] [4] ( projection [2] , component [2] [4] ) of a tuple
The number n is called the length or dimension of the tuple [2] .
Two tuples are equal if their lengths and the corresponding elements are equal [2] [4] :
- {\ displaystyle \ langle a_ {1}, \ ldots, a_ {n} \ rangle = \ langle b_ {1}, \ ldots, b_ {n} \ rangle,} if a
An example of a tuple is an arithmetic vector [2] .
The Cartesian product of n sets is the set of all tuples of length n whose coordinates are taken from these sets [1] [5] [6] :
Tuples of length 2, 3, 4, 5, ... are also called “ ordered pair ”, “ordered three”, “ordered four”, “ordered five”, etc. [2]
Definitions in set theory
In the framework of set theory, tuples can be inductively assigned to sets [1] [7] [8] , for example, as follows [1] [7] :
Defining other objects via tuples
Many mathematical objects are formally defined as tuples. For example, a directed graph is defined as a pair where V is the set of vertices, and E is the subset of pairs in corresponding to arcs of the graph [9] . A point in the n- dimensional space of real numbers is defined as a tuple of length n composed of elements of the set of real numbers.
Oriented multigraph with a set of vertices V , a set of arcs E and an incidence relation can be defined as an ordered troika and if and only if the arc e goes from the vertex a and goes to the vertex b [10] .
In programming
In some programming languages , such as Python or ML , the tuple as a data type is built into the language. An example of using a tuple in Python:
a = ( 1 , 3.14 , 'cat' )
print ( a [ 0 ]) # Print the first element of a tuple
In programming languages with static typing, a tuple differs from the list in that the elements of a tuple can belong to different types and the set of such types is predefined by the type of tuple, and hence the size of the tuple is also defined. On the other hand, collections (lists, arrays) have a restriction on the type of stored items, but do not have a limit on the length. So, for example, in the Rust language, a function can return several values using packing in a tuple:
fn div_with_remainder ( a : i32 , b : i32 ) -> ( i32 , i32 , String ) {
let tmp = ( a / b , a % b );
( tmp . 0 , tmp . 1 , format ! ( "{} + {}" , tmp . 0 , tmp . 1 ))
}
let ( res , rem , repr ) = div_with_remainder ( 5 , 2 );
In functional languages, non-curved functions of several arguments take parameters in the form of a single argument, which is a tuple.
In C ++ , tuple support is implemented as a template of the std :: tuple class [11] (starting with C ++ 11 [12] ) and in the Boost Tuple Library [13] .
The tuple is a standard type in the .NET platform since version 4.0 [14] .
In databases
In relational databases, a tuple is an element of a relationship . For an N -relational relationship, a tuple is an ordered set of N values, one value for each attribute of the relationship.
Notes
- ↑ 1 2 3 4 5 6 7 8 Sudoplatov, Ovchinnikova, 2002 , p. 15.
- ↑ 1 2 3 4 5 6 7 8 Belousov, Tkachev, 2004 , p. 39
- English-Russian Dictionary of Mathematical Terms, 1994 .
- ↑ 1 2 3 Vilenkin, 1975 , p. 75
- ↑ Belousov, Tkachev, 2004 , p. 39-40.
- ↑ Kormen, Leiserson, Rivest, Stein, 2005 , p. 1206.
- ↑ 1 2 Hrbacek, Jech, 1999 , p. 17-18.
- ↑ Kormen, Leiserson, Rivest, Stein, 2005 , p. 1206-1207.
- ↑ Kormen, Leiserson, Rivest, Stein, 2005 , p. 1213.
- ↑ Sudoplatov, Ovchinnikova, 2002 , p. 109.
- ↑ <tuple> . C ++ Reference.
- ↑ std :: tuple . cppreference.com .
- ↑ The Boost Tuple Library - 1.54.0 Unset . Boost C ++ Libraries.
- ↑ Tuple - class . Msdn
Literature
- Sudoplatov S. V., Ovchinnikova E. V. Elements of Discrete Mathematics: Textbook. - M . : INFRA-M, Novosibirsk: NSTU Publishing House, 2002. - 280 p. - (Series "Higher Education"). ISBN 5-16-000957-4 (INFRA-M), ISBN 5-7782-0332-2 (NSTU)
- Belousov A. I., Tkachev S. B. Discrete Mathematics: A Textbook for High Schools / Edited by V. S. Zarubina, A. P. Krishchenko. - 3rd edition, stereotypical. - M .: Publishing House MSTU. N.E. Bauman, 2004. - 744 p. - ISBN 5-7038-1769-2 .
- Kormen, Thomas H., Leiserson, Charles I., Rivest, Ronald L., Stein, Clifford. Algorithms: construction and analysis = Introduction to Algorithms. - 2nd edition. - M .: Williams Publishing House, 2005. - 1296 p. - ISBN 5-8459-0857-4 .
- N. Ya. Vilenkin. Popular combinatorics. - M .: Science, 1975.
- English-Russian Dictionary of Mathematical Terms / Ed. P.S. Aleksandrova. - 2nd, corrected. and add. ed .. - M .: Mir, 1994. - 416 p. - ISBN 5-03-002952-4 .
- Karel Hrbacek, Thomas Jech. Introduction to Set Theory. - Third edition, revised and expanded. - 1999. - ISBN 0-8247-7915-0 .