[m-dev.] list.all2

Mark Brown mark at csse.unimelb.edu.au
Fri Jan 23 14:57:25 AEDT 2009

On 23-Jan-2009, Paul Bone <pbone at csse.unimelb.edu.au> wrote:
> Hi Guys.
> I've created a predicate list.all2 that succeeds if two lists are equal
> and all pairs of elements from each satisfy a predicate.
> :- pred list_all2(pred(A, B), list(A), list(B)).
> :- mode list_all2(pred(in, in) is semidet, in, in) is semidet.
> list_all2(_, [], []).
> list_all2(P, [X | Xs], [Y | Ys]) :-
>     P(X, Y),
>     list_all2(P, Xs, Ys).
> Is this useful enough to be added to the standard library?

It already has been ;-).  There is an (in, in) mode of list.map which
does this.


mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au

More information about the developers mailing list