A.2 apply.pl -- Apply predicates on 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
- Move maplist/N from boot/apply.pl to here.
- Add include/4, include/5, exclude/4, exclude/5

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

[det]include(:Goal, +List1, ?List2)
Filter elements for which Goal succeed. 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.
[det]exclude(:Goal, +List1, ?List2)
Filter elements for which Goal fails. True if List2 contains those elements Xi of List1 for which call(Goal, Xi) fails.
[det]partition(:Pred, +List, ?Included, ?Excluded)
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.
[semidet]partition(:Pred, +List, ?Less, ?Equal, ?Greater)
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.