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:
?- maplist(plus(1), [0, 1, 2], X).
X = [1, 2, 3]
we will phrase this as ``Predicate is applied on ... ''
- maplist(+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
maplist/2
fails.55The maplist/2
predicate replaces the obsolete checklist/2 predicate.
- maplist(+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.
- maplist(+Pred,
?List1, ?List2, ?List3)
-
Apply Pred on all successive triples of elements from List1,
List2 and List3. Fails if Pred can not
be applied to a triple. See the example above.
- sublist(+Pred,
+List1, ?List2)
-
Unify List2 with a list of all elements of List1
to which
Pred applies.