PublicShow sourceapply.pl -- Apply predicates on a list

This module defines meta-predicates that apply a predicate on all members of a list.

See also
- apply_macros.pl provides compile-time expansion for part of this library.
- http://www.cs.otago.ac.nz/staffpriv/ok/pllib.htm
To be done
- Add include/4, include/5, exclude/4, exclude/5
Sourceinclude(:Goal, +List1, ?List2) is det
Filter elements for which Goal succeeds. True if List2 contains those elements Xi of List1 for which call(Goal, Xi) succeeds.
See also
- Older versions of SWI-Prolog had sublist/3 with the same arguments and semantics.
Sourceexclude(:Goal, +List1, ?List2) is det
Filter elements for which Goal fails. True if List2 contains those elements Xi of List1 for which call(Goal, Xi) fails.
Sourcepartition(:Pred, +List, ?Included, ?Excluded) is det
Filter elements of List according to Pred. True if Included contains all elements for which call(Pred, X) succeeds and Excluded contains the remaining elements.
Sourcepartition(:Pred, +List, ?Less, ?Equal, ?Greater) is semidet
Filter List according to Pred in three sets. For each element Xi of List, its destination is determined by call(Pred, Xi, Place), where Place must be unified to one of <, = or >. Pred must be deterministic.
Sourcemaplist(:Goal, ?List)
True if Goal can successfully be applied on all elements of List. Arguments are reordered to gain performance as well as to make the predicate deterministic under normal circumstances.
Sourcemaplist(:Goal, ?List1, ?List2)
As maplist/2, operating on pairs of elements from two lists.
Sourcemaplist(:Goal, ?List1, ?List2, ?List3)
As maplist/2, operating on triples of elements from three lists.
Sourcemaplist(:Goal, ?List1, ?List2, ?List3, ?List4)
As maplist/2, operating on quadruples of elements from four lists.
Sourcefoldl(:Goal, +List, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +List3, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +List3, +List4, +V0, -V)
Fold a list, using arguments of the list as left argument. The foldl family of predicates is defined by:
foldl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0, Vn) :-
      P(X11, ..., Xm1, V0, V1),
      ...
      P(X1n, ..., Xmn, V', Vn).
Sourcescanl(:Goal, +List, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +List3, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +List3, +List4, +V0, -Values)
Left scan of list. The scanl family of higher order list operations is defined by:
scanl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0,
      [V0,V1,...,Vn]) :-
      P(X11, ..., Xm1, V0, V1),
      ...
      P(X1n, ..., Xmn, V', Vn).
Sourcefoldl(:Goal, +List, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +List3, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +List3, +List4, +V0, -V)
Fold a list, using arguments of the list as left argument. The foldl family of predicates is defined by:
foldl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0, Vn) :-
      P(X11, ..., Xm1, V0, V1),
      ...
      P(X1n, ..., Xmn, V', Vn).
Sourcefoldl(:Goal, +List, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +List3, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +List3, +List4, +V0, -V)
Fold a list, using arguments of the list as left argument. The foldl family of predicates is defined by:
foldl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0, Vn) :-
      P(X11, ..., Xm1, V0, V1),
      ...
      P(X1n, ..., Xmn, V', Vn).
Sourcefoldl(:Goal, +List, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +List3, +V0, -V)
Sourcefoldl(:Goal, +List1, +List2, +List3, +List4, +V0, -V)
Fold a list, using arguments of the list as left argument. The foldl family of predicates is defined by:
foldl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0, Vn) :-
      P(X11, ..., Xm1, V0, V1),
      ...
      P(X1n, ..., Xmn, V', Vn).
Sourcescanl(:Goal, +List, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +List3, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +List3, +List4, +V0, -Values)
Left scan of list. The scanl family of higher order list operations is defined by:
scanl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0,
      [V0,V1,...,Vn]) :-
      P(X11, ..., Xm1, V0, V1),
      ...
      P(X1n, ..., Xmn, V', Vn).
Sourcescanl(:Goal, +List, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +List3, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +List3, +List4, +V0, -Values)
Left scan of list. The scanl family of higher order list operations is defined by:
scanl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0,
      [V0,V1,...,Vn]) :-
      P(X11, ..., Xm1, V0, V1),
      ...
      P(X1n, ..., Xmn, V', Vn).
Sourcescanl(:Goal, +List, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +List3, +V0, -Values)
Sourcescanl(:Goal, +List1, +List2, +List3, +List4, +V0, -Values)
Left scan of list. The scanl family of higher order list operations is defined by:
scanl(P, [X11,...,X1n], ..., [Xm1,...,Xmn], V0,
      [V0,V1,...,Vn]) :-
      P(X11, ..., Xm1, V0, V1),
      ...
      P(X1n, ..., Xmn, V', Vn).