[m-dev.] for review: new library preds

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jul 19 12:05:58 AEST 2000

On 19-Jul-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> Add several useful library predicates.

The new predicates should be mentioned in the NEWS file.

> +	% list__all_true(Predicate, List) succeeds if and only if
> +	% Predicate succeeds on all the elements of List.
> +:- pred list__all_true(pred(T), list(T)).
> +:- mode list__all_true(pred(in) is semidet, in) is semidet.
> +
> +	% list__all_false(Predicate, List) succeeds if and only if
> +	% Predicate fails on all the elements of List.
> +:- pred list__all_false(pred(T), list(T)).
> +:- mode list__all_false(pred(in) is semidet, in) is semidet.
> +list__all_true(_, []).
> +list__all_true(P, [X | Xs]) :-
> +	call(P, X),
> +	list__all_true(P, Xs).
> +
> +list__all_false(_, []).
> +list__all_false(P, [X | Xs]) :-
> +	\+ call(P, X),
> +	list__all_false(P, Xs).

Hmm, are these really worthwhile?
Why not write

	all [X] (list__member(X, L) => P(X))

instead of 

	list__all_true(P, L)


	list__all_true((pred(X::in) is semidet :- P(X)), L)

?  Using an explicit quantifier is clearer, IMHO,
and in the case where you would need to pass a lambda
expression to list__all_true it is also more concise.
I don't think these two predicates are sufficiently useful
to justify inclusion in the standard library.

But the other procedures you've added all look like reasonable additions,

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        |     -- the last words of T. S. Garp.
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au

More information about the developers mailing list