B.7 Tuples
A tuple is a sequence of elements of potentially mixed types. Formally, a tuple is an element e of a Cartesian product of a given number of sets: e ∈ (S1 × S2 × … × Sn). A two-element tuple is called a pair [e.g., e ∈ (A × B)]. A three-element tuple is called a triple [e.g., e ∈ (A × B × C)]. A tuple typically contains unordered, heterogeneous elements akin to a struct in C with the exception that a tuple is indexed by numbers (like a list) rather than by field names (like a struct). While tuples can be heterogeneous, in a list of tuples, each tuple in the list must be of the same type. Elements of a tuple are accessible by prefacing the tuple with #n, where n is the number of the element, starting with 1:
The response ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access