[ library(lists) | Reference Manual | Alphabetic Index ]

checklist(+Pred, +List)

Succeeds if Pred(Elem) succeeds for every element of List.
+Pred
Atom or compound term.
+List
List.

Description

checklist/3 succeeds if for every element of List, the invocation of Pred with one aditional argument which is this element succeeds.

The definition of this Prolog library predicate is:

:- tool(checklist/3, checklist_body/4).

checklist_body(_, [], _).
checklist_body(Pred, [Head|Tail], M) :-
    call(Pred, Head)@M,
    checklist_body(Pred, Tail, M).
This predicate does not perform any type testing functions.

Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

Fail Conditions

Fails if at least for one element of List the invocation of Pred with this additional argument fails.

Resatisfiable

Resatisfiable if at least for one element of List the invocation of Pred with this additional argument is resatisfiable.

Examples

Success:
  checklist(integer, [1, 3, 5]).
  checklist(spy, [var/1, functor/3]).

Fail:
  checklist(current_op(_, _), [+, -, =]).
  (fails because the precedence of = does not match that of +)



See Also

maplist / 3