4.30 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:

?- maplist(plus(1), [0, 1, 2], X).

X = [1, 2, 3]

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

Currently, the predicates below are defined as built-in predicates. It is planned to move these to library(apply). See section A.2 for more predicates. The library(apply_macros) defines macros that compile some of these meta-calling constructs away.

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.58The 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.