Clever Geek Handbook
📜 ⬆️ ⬇️

Tuple (informatics)

A tuple is an ordered set of fixed length.

Content

In Math

Let sets be givenAone,A2,...,An {\ displaystyle A_ {1}, A_ {2}, \ ldots, A_ {n}}   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 elementsxone,x2,...,xn, {\ displaystyle x_ {1}, x_ {2}, \ ldots, x_ {n},}   Wherexi∈Ai {\ displaystyle x_ {i} \ in A_ {i}}   forone⩽i⩽n. {\ displaystyle 1 \ leqslant i \ leqslant n.}   A tuple is indicated by listing the coordinates in angle or parentheses [1] :

⟨xone,x2,...,xn⟩{\ displaystyle \ langle x_ {1}, x_ {2}, \ ldots, x_ {n} \ rangle}  

or

(xone,x2,...,xn).{\ displaystyle (x_ {1}, x_ {2}, \ ldots, x_ {n}).}  

Elementxi {\ displaystyle x_ {i}}   is called the i- th coordinate [1] [4] ( projection [2] , component [2] [4] ) of a tuple⟨xone,x2,...,xn⟩. {\ displaystyle \ langle x_ {1}, x_ {2}, \ ldots, x_ {n} \ rangle.}  

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] :

⟨aone,...,an⟩=⟨bone,...,bn⟩,{\ displaystyle \ langle a_ {1}, \ ldots, a_ {n} \ rangle = \ langle b_ {1}, \ ldots, b_ {n} \ rangle,}   if aai=bi,i=one,n¯. {\ displaystyle a_ {i} = b_ {i}, i = {\ overline {1, n}}.}  

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] :

Aone×...×An={⟨xone,...,xn⟩|xi∈Ai,i=one,n¯}.{\ displaystyle A_ {1} \ times \ ldots \ times A_ {n} = \ {\ langle x_ {1}, \ ldots, x_ {n} \ rangle \ mid x_ {i} \ in A_ {i}, i = {\ overline {1, n}} \}.}  

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] :

  • ⟨⟩⇌∅,{\ displaystyle \ langle \ rangle \ rightleftharpoons \ emptyset,}  
  • ⟨xone⟩⇌xone,{\ displaystyle \ langle x_ {1} \ rangle \ rightleftharpoons x_ {1},}  
  • ⟨xone,x2⟩⇌{{xone},{xone,x2}},{\ displaystyle \ langle x_ {1}, x_ {2} \ rangle \ rightleftharpoons \ {\ {x_ {1} \}, \ {x_ {1}, x_ {2} \} \},}  
  • ⟨xone,x2,x3⟩⇌⟨⟨xone,x2⟩,x3⟩,{\ displaystyle \ langle x_ {1}, x_ {2}, x_ {3} \ rangle \ rightleftharpoons \ langle \ langle x_ {1}, x_ {2} \ rangle, x_ {3} \ rangle,}  
  • ⟨xone,x2,x3,xfour⟩⇌⟨⟨xone,x2,x3⟩,xfour⟩,...{\ displaystyle \ langle x_ {1}, x_ {2}, x_ {3}, x_ {4} \ rangle \ rightleftharpoons \ langle \ langle x_ {1}, x_ {2}, x_ {3} \ rangle, x_ {4} \ rangle, \ ldots}  
  • ⟨xone,...,xn⟩⇌⟨⟨xone,...,xn-one⟩,xn⟩.{\ displaystyle \ langle x_ {1}, \ ldots, x_ {n} \ rangle \ rightleftharpoons \ langle \ langle x_ {1}, \ ldots, x_ {n-1} \ rangle, x_ {n} \ rangle.}  

Defining other objects via tuples

Many mathematical objects are formally defined as tuples. For example, a directed graph is defined as a pair⟨V,E⟩, {\ displaystyle \ langle V, E \ rangle,}   where V is the set of vertices, and E is the subset of pairs inV×V, {\ displaystyle v \ times v,}   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 relationP⊆V×E×V {\ displaystyle P \ subseteq V \ times E \ times V}   can be defined as an ordered troika⟨V,E,P⟩, {\ displaystyle \ langle V, E, P \ rangle,}   and⟨a,e,b⟩∈P {\ displaystyle \ langle a, e, b \ rangle \ in P}   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. ↑ 1 2 3 4 5 6 7 8 Sudoplatov, Ovchinnikova, 2002 , p. 15.
  2. ↑ 1 2 3 4 5 6 7 8 Belousov, Tkachev, 2004 , p. 39
  3. English-Russian Dictionary of Mathematical Terms, 1994 .
  4. ↑ 1 2 3 Vilenkin, 1975 , p. 75
  5. ↑ Belousov, Tkachev, 2004 , p. 39-40.
  6. ↑ Kormen, Leiserson, Rivest, Stein, 2005 , p. 1206.
  7. ↑ 1 2 Hrbacek, Jech, 1999 , p. 17-18.
  8. ↑ Kormen, Leiserson, Rivest, Stein, 2005 , p. 1206-1207.
  9. ↑ Kormen, Leiserson, Rivest, Stein, 2005 , p. 1213.
  10. ↑ Sudoplatov, Ovchinnikova, 2002 , p. 109.
  11. ↑ <tuple> (Unsolved) . C ++ Reference.
  12. ↑ std :: tuple (Unsolved) . cppreference.com .
  13. ↑ The Boost Tuple Library - 1.54.0 ( Unset ) . Boost C ++ Libraries.
  14. ↑ Tuple - class (Unsolved) . 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 .

Links

  • Deep into the Python language: 1.9. Tuples
Source - https://ru.wikipedia.org/w/index.php?title=Cortege_ (informatics )& oldid = 98535824


More articles:

  • Atlantic Ocean
  • Vyazemsky (city)
  • Viola
  • Garliava
  • Ust-Izhora
  • Road (film, 1954)
  • Maya (People)
  • "Time Machine" - XX!

All articles

Clever Geek | 2019