Tuples (Triple, Quadruple, Quintuple…)
Pairs are 'doubles.' Threes are 'triples.' After that the words start sounding made up: quadruple, quintuple, sextuple. They aren't made up. They follow a Latin numbering pattern that programmers have inherited from mathematicians, and the rules are worth knowing.
A tuple is a finite ordered list of elements. In programming, tuples show up everywhere: a coordinate pair like (3, 5), a database row, the return value of a function that needs to hand back two things, an RGB color (255, 100, 0). The word itself is a back-formation from the Latin sequence that gives us double, triple, quadruple, and on. The series stops being intuitive somewhere around quintuple, and a lot of working programmers have looked up "what comes after sextuple" at least once. Worth getting the whole sequence straight, because the names map directly to a real mathematical concept.
The Naming Sequence
The Latin-derived names go: single, double, triple, quadruple, quintuple, sextuple, septuple, octuple, nonuple, decuple. Past ten, you're either inventing names ad-hoc (centuple at 100, millituple if you must) or just saying "an n-tuple" and being done with it. The mathematical convention is to use n-tuple for any size, with the named forms reserved for the small cases that come up often.
The English suffix "-tuple" itself is a 17th-century construct. It's the back-end of words like quintuple (from Latin quintus, fifth) split off and reused as a generic suffix. Mathematicians lifted it to mean a sequence of length n, and computer science inherited that meaning intact.
What a Tuple Actually Is
Three properties define a tuple. It's ordered: (1, 2, 3) is not the same as (3, 2, 1). It's finite: you can't have an infinite tuple, you'd call that a sequence. And the elements can be different types: a tuple can hold an integer, a string, and a float in three positions, which distinguishes it from a vector or a homogeneous array.
The classic example in math is a coordinate. A point in 2D space is a 2-tuple (an ordered pair). A point in 3D space is a 3-tuple. Spacetime requires a 4-tuple. Generalizing past three or four dimensions is where the named forms stop being useful and the n-tuple notation takes over.
Tuples in Programming
Most modern programming languages have a built-in tuple type. Python's tuples are immutable and use parentheses: (1, "a", 3.14). Rust has tuples as a first-class type with parentheses syntax. Swift, Scala, and Kotlin have similar constructs. JavaScript notably doesn't have tuples as a distinct type; programmers fake them with arrays.
The reason tuples earn their own type instead of being collapsed into a list or array is that they capture intent. A 3-element list of floats might be three samples of a temperature reading; a 3-tuple of floats is more naturally a 3D coordinate. A list is "a collection of homogeneous things, possibly variable length." A tuple is "a fixed-length record of related values that may be different types." The distinction shows up in how compilers reason about your code and how readers understand it.
Where the Names Matter
In statistics, a doublet, triplet, or quadruplet often refers to a multi-element observation in time series data. In linguistics, a tuple shows up as a feature vector for a word: (part-of-speech, gender, plurality, tense). In databases, every row of a relational table is, formally, a tuple in the relational algebra sense, where the column types constitute the tuple's type signature.
The names also matter for SQL window functions: tuple-of-values versus scalar, and for the conceptual difference between an n-tuple and a record (a tuple where the positions have names). A relational database row is, strictly, a labeled tuple, and the labels are the column names.
The Practical Rule
For most working programmers, the rule worth remembering is: if you have a small fixed number of values that belong together but aren't homogeneous, use a tuple. If you find yourself indexing into the tuple by position more than two or three times, that's a sign that the tuple should become a struct or a record with named fields. The named forms (triple, quadruple) are a hint that you're past the point where positional access is readable. If you can't say "the third element" without context-switching, the data structure has outgrown the tuple shape.
Written by
Tech Talk News Editorial
Tech Talk News covers engineering, AI, and tech investing for people who build and invest in technology.