next up previous contents index
Next: Forall Up: Built-in predicates Previous: Finding all Solutions to   Contents   Index

Invoking Predicates on all Members of a List

All the predicates in this section call a predicate on all members of a list or until the predicate called fails. The predicate is called via call/[2..], which implies common arguments can be put in front of the arguments obtained from the list(s). For example:


\begin{code}
?- maplist(plus(1), [0, 1, 2], X).
\par X = [1, 2, 3]
\end{code}

we will phrase this as ``Predicate is applied on ...''

checklist2+Pred, +List Pred is applied successively on each element of List until the end of the list or Pred fails. In the latter case the checklist2 fails. maplist3+Pred, ?List1, ?List2 Apply Pred on all successive pairs of elements from List1 and List2. Fails if Pred can not be applied to a pair. See the example above. sublist3+Pred, +List1, ?List2 Unify List2 with a list of all elements of List1 to which Pred applies.


next up previous contents index
Next: Forall Up: Built-in predicates Previous: Finding all Solutions to   Contents   Index
Dr. Richard Botting 2001-12-12