repost after modifications: additions to map/tree234

Lee Naish lee at cs.mu.OZ.AU
Mon Mar 30 15:56:26 AEST 1998


Thomas Charles CONWAY <conway at cs.mu.OZ.AU> writes:

>library/map.m:
>	added map__foldl/4 and map__map_values/3 which forward to the
>	corresponding predicates in tree234.

I suggest using map__fold/4 rather than map__foldl/4.  foldr and foldl
are different if the function applied is not associative (something
the system is unlikely to check).  Similarly if the function map__foldl
uses is not associative the result will depend on the order in which
things are inserted into the tree and the insertion algorithm (something
your average user doesn't want to think about).  Using the name
map__foldl gives the impression that it would return the same result
foldl would return if a (sorted?) list was used instead of a 234 tree.
The documentation should also note that the result will be unpredictable
if the function is not associative (unless you know the shape of the
tree exactly, which is bearable at the level of tree234 but not at the
more abstract level of maps).

	lee



More information about the developers mailing list