for review: assoc_list__map_from_corresponding_lists

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Jan 25 14:41:39 AEDT 1998


On 22-Jan-1998, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> 
> Here's a quick change to the library that was suggested to
> help with my layouts change.
> 
> ===================================================================
> 
> library/assoc_list.m:
> 	Add a new predicate:
> 		assoc_list__map_from_corresponding_lists
> 	which applies a predicate to the corresponing list
> 	elements before packaging them into an assoc list.

I thought a bit more about this, and I think the real problem with this
change was this: why package them into an assoc list, rather than just
an arbitrary list?  That just unnecessarily restricts the usefulness
of this predicate.  If you look at your layouts change, it in fact
couldn't make use of the predicate you proposed adding.

If you extend the functionality in this way, then I think that the
predicate _would_ be worthy of inclusion in the standard library.

The name of the predicate should also change.
Perhaps `list__map_corresponding_lists' would be a reasonable choice.

In Haskell, there is a function `zipWith' which does the same
thing as the modified functionality that I've suggested.  Also
Haskell's assoc_list__from_corresponding_lists is known as `zip'.
But Mercury's list__zip has a different meaning than Haskell's zip.

Incidentally, is Mercury's list__zip useful?  If so, what for?
Has anyone other than the author ever used it?

The Haskell names are quite evocative and memorable, and are thus
pretty clear even though they're quite short, but arguably the name
`zip' better suits the functionality of Mercury's list__zip rather than
the Haskell zip.  Hmm, how about `splice'?

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list