Can someone define what a tuple is for me?

In summary: I see something and say, "look, there's a tuple!". I would really want a clear definition in layman's terms so that I can be able to have these concepts clear in my mind, in particular the concept of a tuple.In summary, a tuple is an ordered list of elements, where the position of each element holds a specific meaning. The order of the elements is important and distinguishes it from a set. Tuples are commonly used in mathematics and can be seen in real life in situations such as organizing a list of airplanes at an airport or recording the top three heaviest aircraft. While the exact name of a tuple may not be important in practice, it becomes
  • #1
Solid Snake
26
0
Ok, so I read that a tuple is an ordered list of n elements, where n is a non-negative integer. Sometimes I get confused with tuples and partially ordered sets. So if I organized a list of all the airplanes in a particular airport, would that be a tuple, or would that be a set? I'm leaning towards it being a set, but by reading the definition of a tuple, I can also see it being a tuple. Other than a point in a graph, or a vector, where else in real life would I see something and say, "look, there's a tuple!". I would really want a clear definition in layman's terms so that I can be able to have these concepts clear in my mind, in particular the concept of a tuple.
 
Mathematics news on Phys.org
  • #2
The trick with tuples is that the position of the number in sequence has a meaning ... like the number 157 is a 3-tuple because the positions code hundreds, tens, and ones from left to right. The order has to be important ... like 1st, 2nd, 3rd ... i.e. a set of polygons could be described by a tuple where the nth entry in the list is the number of polygons with n sides in the set. If I draw the polygons from the set one at a time, then the sequence of polygons could be a tuple.
Ordered pairs are a list of 2-tuples in the order that they are to be drawn on a graph ... (x_i,y_i) if there are a finite number of them [edit: I am corrected, you cannot have an infinity-tuple] the position of the number in the list refers to a component of position on a graph.

In the end you define a mathematical object by it's list of properties ...
Distinguish from a set by:
1. ##(1,2,3)\neq (3,2,1)## while ##\{1,2,3\} = \{3,2,1\}##
2. Multiple entries are allowed: ##(1,1,3)## would be a tuple from set ##\{1,3\}##
3. Must have a finite number of elements.

So for the set of aircraft at an airport: organize by, say, weight, then that is just a sorted list. But if you have, say, 10 gates at the airport, then you can define a 10-tuple that stores the flight-number currently docked at each gate (0000 for empty gate, say). You could presumably define weight ranges so-many tonnes wide, and record the number of aircraft at the airport that fit in each weight range ... store that as a tuple. Similarly the top 3 heaviest aircraft would be a 3-tuple is the 1st position were heaviest etc. The names of the medal winners at an olympic event (if in a specific order each time) would be a 3-tuple like that.

It's unusual, in practise, that you actually care about the exact name of a mathematical structure like this though: you just use whatever seems appropriate at the time. Certainly not worth focussing on... this is probably the most I've used the word in a decade. The time the name becomes important is when you want to use someone elses result for a general property - in that case you realize the property and look up the name of the theorem that applies. (The other time is in an exam and you are specifically asked...) Thus: this is where I found out that I'm wrong ;)
 
  • #3
Simon Bridge said:
So for the set of aircraft at an airport: organize by, say, weight, then that is just a sorted list. But if you have, say, 10 gates at the airport, then you can define a 10-tuple that stores the flight-number currently docked at each gate (0000 for empty gate, say). You could presumably define weight ranges so-many tonnes wide, and record the number of aircraft at the airport that fit in each weight range ... store that as a tuple. Similarly the top 3 heaviest aircraft would be a 3-tuple is the 1st position were heaviest etc. The names of the medal winners at an olympic event (if in a specific order each time) would be a 3-tuple like that.

It's unusual, in practise, that you actually care about the exact name of a mathematical structure like this though: you just use whatever seems appropriate at the time. Certainly not worth focussing on... this is probably the most I've used the word in a decade. The time the name becomes important is when you want to use someone elses result for a general property - in that case you realize the property and look up the name of the theorem that applies. (The other time is in an exam and you are specifically asked...) Thus: this is where I found out that I'm wrong ;)

So just to make sure I understand you well, can I understand a tuple to be a list of data where each element is related to each other and ordered in that each index holds a value representing a specific thing?

Thank you so much for your reply.
 
  • #4
The element position in the list should have meaning - the elements are related to each other in that they all appear on the list.
Examples of what I mean by the position in the list having meaning have been provided above: there is something special about being first, second, fifty-fourth or whatever on the list so that the order of the elements matters.

Imagine the kind of list where you number the entries ... a tuple is just such a list, only the numbers are implied by the position of the entry: #1 on the list is the 1st entry in the tuple.

Note: Everything is related to everything else in some way, though, usually, you don't bother making the list unless the elements are related in some way you find important.
 
  • #5
Solid Snake said:
So if I organized a list of all the airplanes in a particular airport, would that be a tuple, or would that be a set? I'm leaning towards it being a set, but by reading the definition of a tuple, I can also see it being a tuple. Other than a point in a graph, or a vector, where else in real life would I see something and say, "look, there's a tuple!". I would really want a clear definition in layman's terms so that I can be able to have these concepts clear in my mind, in particular the concept of a tuple.
Using your example of an airport, a good example of a tuple would be (flight number, destination, departure time) or (flight number, date, seat number, passenger name).
 

FAQ: Can someone define what a tuple is for me?

1. What is a tuple in computer science?

A tuple is a data structure in computer science that is used to store a sequence of elements. It is similar to an array, but unlike an array, the elements in a tuple can be of different data types.

2. How is a tuple different from a list?

A tuple is similar to a list in that it stores a sequence of elements, but it differs in two key ways. First, tuples are immutable, meaning they cannot be changed once created. Second, tuples can hold elements of different data types while lists can only hold elements of the same data type.

3. What is the syntax for creating a tuple?

A tuple is created using parentheses, with each element separated by a comma. For example: (1, 2, "hello", True)

4. How are tuples used in programming?

Tuples are commonly used in programming to store related data that should not be modified, such as coordinates or database records. They are also used to return multiple values from a function.

5. Can tuples be nested?

Yes, tuples can be nested, meaning they can contain other tuples as elements. This allows for more complex data structures to be created and manipulated in a program.

Similar threads

Back
Top