[mercury-users] There's nowt so boring as writing thesis

Thomas Charles CONWAY conway at cs.mu.OZ.AU
Mon Sep 14 09:27:56 AEST 1998


Ralph Becket, you write:
> It strikes me that the current Mercury libraries don't provide that
> great a range of higher order utilities.  For example, mapping and
> filtering binary trees would be a good one.  I volunteer to code
> something up after this month if there's any call for it.

The current development sources contain some HO predicates on maps.
One of the problems is that things like 'filter' don't work so well
on trees, especially balanced trees. Half the time you'd be no better
off with a tree specific predicate than:

<some HO map predicate>(Pred, Map0, Map, ....) :-
	map__to_assoc_list(Map0, List0),
	<some HO list predicate>(Pred, List0, List, ....),
	map__from_assoc_list(List, Map).

Certainly, we could provide such predicates, but if a representation
change is necessary, then it's probably not a bad idea to make it
explicit so that the programmer can organise his code to minimise the
number of representation changes.

Thomas
-- 
Thomas Conway <conway at cs.mu.oz.au>
Nail here [] for new monitor.  )O+



More information about the users mailing list