Ariel Scolnicov wrote:
> Damian Conway <[EMAIL PROTECTED]> writes:
>
> > Just to point out that the standard CS term is "merge".
>
> `merge' produces a list of items from 2 (or more) lists of items;
> `zip' produces a list of pairs (or tuples) of items from 2 (or more)
> lists of items.  So in a language like Haskell which uses square
> brackets for lists and round for tuples (and `==' for equality, etc.):
>
>     merge [1,2,3,4],[5,6,7,8] == [1,5,2,6,3,7,4,8]
>
> and
>
>     zip [1,2,3,4],[5,6,7,8] == [(1,5),(2,6),(3,7),(4,8)]
>
This brings up an interesting question... which behaviour would we prefer?
Currently the RFC defines zip() as producing a flat list, rather than a list
of references to arrays. Of course, you can always say:

  $haskell_zip = partition (zip @^listOfLists, scalar @^listOfLists);

which is why I figured the flat-by-default version would be more useful. If
we created the partitioned version by default, then the other version would
be:

  $haskell_merge = map @^, @listOfLists;

which seems a little harder to evaluate lazily (for an individual item in a
tuple, that is--evaluating a whole tuple lazily would be straightforward).

Assuming that the current definition remains, 'merge' does seem more
appropriate (and less offensive to the 'functionally challenged' ;-)


Reply via email to