apply_macros.pl
provides compile-time expansion for part
of this library. This module defines meta-predicates that apply a predicate on all members of a list.
call(Goal, Xi)
succeeds.
call(Goal, Xi)
fails.call(Pred, X)
succeeds and
Excluded contains the remaining elements.call(Pred, Xi, Place)
,
where Place must be unified to one of <
, =
or >
.
Pred must be deterministic.call(Goal, ElemIn, _)
fails are
omitted from ListOut. For example (using library(yall)
):
?- convlist([X,Y]>>(integer(X), Y is X^2), [3, 5, 4.4, 2], L). L = [9, 25, 4].
library(maplist)
and SICStus
library(lists)
.foldl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0, Vn) :- P(X11, ..., Xm1, V0, V1), ... P(X1n, ..., Xmn, V', Vn).
scanl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0, [V0,V1,...,Vn]) :- P(X11, ..., Xm1, V0, V1), ... P(X1n, ..., Xmn, V', Vn).