martind1
Aug 20th, 2002, 09:12 AM
What is a tuple and how do i handle a function that returns it?
JoshT
Aug 20th, 2002, 10:52 AM
? Is a tuple a row from a database table ?
martind1
Aug 20th, 2002, 10:55 AM
well if it is, how do i handel it?
ccoder
Aug 20th, 2002, 07:48 PM
I just did a Google search and pulled this from one of the first hits:
"A tuple (or n-tuple) is a fixed size collection of elements. Pairs, triples, quadruples etc. are tuples. In a programming language, a tuple is a data object containing other objects as elements. These element objects may be of different types.
Tuples are convenient in many circumstances. For instance, tuples make it easy to define functions that return more than one value.
Some programming languages, such as ML, Python and Haskell, have built-in tuple constructs. Unfortunately C++ does not. To compensate for this "deficiency", the Boost Tuple Library implements a tuple construct using templates. "
From another:
"There are six sequence types: strings, Unicode strings, lists, tuples, buffers, and xrange objects.
Strings literals are written in single or double quotes: 'xyzzy', "frobozz". See chapter 2 of the Python Reference Manual for more about string literals. Unicode strings are much like strings, but are specified in the syntax using a preceeding "u" character: u'abc', u"def". Lists are constructed with square brackets, separating items with commas: [a, b, c]. Tuples are constructed by the comma operator (not within square brackets), with or without enclosing parentheses, but an empty tuple must have the enclosing parentheses, e.g., a, b, c or (). A single item tuple must have a trailing comma, e.g., (d,). "
You may be able to find some good examples of usage.