[Haskell-cafe] history of tuples vs pairs
David Menendez
dave at zednenem.com
Wed Jun 25 13:29:53 EDT 2008
2008/6/25 Conal Elliott <conal at conal.net>:
> I have a foggy memory that early ML had only binary pairing, nesting for
> n-tuples. Can anyone confirm this memory. If so, does anyone remember the
> rationale for going to n-tuples? Performance, perhaps?
>
> Similarly, did the Haskell designers consider pairs as an alternative to
> n-ary tuples?
I think performance was part of it: accessing the nth element of a
tuple is O(1), but the nth element of a nested pair is O(n).
On the other hand, you can't internally represent nested pairs as
n-tuples because of laziness. (a,(b,c)) has elements of the form
(x,_|_) that don't correspond to any triple.
--
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>
More information about the Haskell-Cafe
mailing list