3 ms·
It doesn't have "true tuples" but you can do multiple returns in a tuple-like way and there is syntax for unpacking it. While a pair can't be stored in a single
by nv-vn 11y ago
It doesn't have "true tuples" but you can do multiple returns in a tuple-like way and there is syntax for unpacking it. While a pair can't be stored in a single variable, you can just manually unpack and repack them for a similar effect to what tuples can do. For the record, most languages don't have indexable tuples as far as I'm aware and make you unpack them with some form of pattern matching.
- pcwalton 11y ago> For the record, most languages don't have indexable tuples as far as I'm aware Most languages with tuples have indexable tuples either via language syntax or library functions. (For example, OCaml practically does, with fst and snd.) > It doesn't have "true tuples" but you can do multiple returns in a tuple-like way and there is syntax for unpacking it. There's a large difference between having multiple return values and having first-class tuple values.
- nv-vn 11y agoHaskell/OCaml style "fst" and "snd" functions can't index arbitrary tuples (they only work on 2-tuples/pairs): http://i.imgur.com/PbhNxmu.png http://i.imgur.com/PbhNxmu.png.