[m-dev.] list__map_foldl

Philip Dart philip at cs.mu.oz.au
Thu Jun 12 13:58:49 AEST 1997


How about adding this predicate to the library?
It is used 11 times in muz so it must be useful :-)

Philip
---

	% list__map_foldl(Pred, InList, OutList, Start, End) calls Pred with
	% an accumulator (with the initial value of Start) on each element of
	% InList (working left-to-right) to transform InList into OutList.
	% The final value of the acumulator is returned in End.
:- pred list__map_foldl(pred(X, Y, Z, Z), list(X), list(Y), Z, Z).
:- mode list__map_foldl(pred(in, out, di, uo) is det, in, out, di, uo) is det.
:- mode list__map_foldl(pred(in, out, in, out) is det, in, out, in, out) is det.
:- mode list__map_foldl(pred(in, out, in, out) is semidet, in, out, in, out)
								is semidet.

list__map_foldl(_, [],  []) -->
	[].
list__map_foldl(P, [H0|T0], [H|T]) -->
	P(H0, H),
	list__map_foldl(P, T0, T).



More information about the developers mailing list