Did you know ... Search Documentation:
Pack prolog_library_collection -- prolog/call_ext.pl
PublicShow source
 bagof(+Template:T, :Goal_0, -Bag:list(T), +Zero:list(T)) is det
 call_boolean(:Goal_0, +Boolean:boolean) is semidet
call_boolean(:Goal_0, -Boolean:boolean) is det
Returns whether Goal_0 succeeded once as a Boolean.
 call_det_when(:Cond_0, :Goal_0)
Calls Goal_0 once when Cond_0 succeeds; otherwise calls Goal_0 normally.
 call_det_when_ground(:Goal_0)
 call_det_when_ground(?Term:term, :Goal_0)
Call Goal_0 deterministically in case Term is ground. Otherwise call Goal_0 normally.
 call_forall(:A_1, :B_1)
 call_if_ground(:Goal_0) is det
 call_if_ground(?Term:term, :Goal_0) is det
 call_if_nonvar(?Term:term, :Goal_0) is det
 call_must_be(:Goal_1, @Term) is det
Checks whether Term belongs to the set of terms denoted by Goal_1.

Assumes that terms enumerated by `Goal_1' are ground.

 call_pair(:Goal_2, +Pair1:pair, -Pair2:pair) is det
Calls Goal_2 on the values of Pair1 and Pair2.
 call_statistics(:Goal_0, +Key, -Delta) is det
 call_stats(:Select_1, :Goal_1, -Stats:dict) is det
_{ cputime: float, inferences: nonneg, max: float, min: float, walltime: float }
 call_stats_n(+Repeats:positive_integer, :Goal_0, -Stats:dict) is det
_{ cputime: float, inferences: nonneg, max: float, min: float, walltime: float }
 call_warning(:Goal_0) is semidet
 call_when_ground(:Goal_0) is det
 call_when_ground(?Term:term, :Goal_0) is det
 equal_under(:Goal_2, +A:term, +B:term) is semidet
Succeeds iff `A' and `B' are equal under transformation `Goal_2'.
 is_det(:Goal_0) is semidet
 maplist(:Goal_5, ?Args1:list, ?Args2:list, ?Args3:list, ?Args4:list, ?Args5:list)
 permlist(:Goal_2, ?Args1:list(term), ?Args2:list(term)) is det
 true(?Arg1) is det
 true(?Arg1, ?Arg2) is det
 true(?Arg1, ?Arg2, ?Arg3) is det
Always succeeds.

Re-exported predicates

The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.

 include(: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
- exclude/3, partition/4, convlist/3.
Compatibility
- Older versions of SWI-Prolog had sublist/3 with the same arguments and semantics.
 exclude(: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.
See also
- include/3, partition/4
 partition(: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.
See also
- include/3, exclude/3, partition/5.
 partition(: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.
See also
- partition/4
 maplist(:Goal, ?List1)
 maplist(:Goal, ?List1, ?List2)
 maplist(:Goal, ?List1, ?List2, ?List3)
 maplist(:Goal, ?List1, ?List2, ?List3, ?List4)
True if Goal is successfully applied on all matching elements of the list. The maplist family of predicates is defined as:
maplist(G, [X_11, ..., X_1n],
           [X_21, ..., X_2n],
           ...,
           [X_m1, ..., X_mn]) :-
   call(G, X_11, ..., X_m1),
   call(G, X_12, ..., X_m2),
   ...
   call(G, X_1n, ..., X_mn).

This family of predicates is deterministic iff Goal is deterministic and List1 is a proper list, i.e., a list that ends in [].

 maplist(:Goal, ?List1)
 maplist(:Goal, ?List1, ?List2)
 maplist(:Goal, ?List1, ?List2, ?List3)
 maplist(:Goal, ?List1, ?List2, ?List3, ?List4)
True if Goal is successfully applied on all matching elements of the list. The maplist family of predicates is defined as:
maplist(G, [X_11, ..., X_1n],
           [X_21, ..., X_2n],
           ...,
           [X_m1, ..., X_mn]) :-
   call(G, X_11, ..., X_m1),
   call(G, X_12, ..., X_m2),
   ...
   call(G, X_1n, ..., X_mn).

This family of predicates is deterministic iff Goal is deterministic and List1 is a proper list, i.e., a list that ends in [].

 maplist(:Goal, ?List1)
 maplist(:Goal, ?List1, ?List2)
 maplist(:Goal, ?List1, ?List2, ?List3)
 maplist(:Goal, ?List1, ?List2, ?List3, ?List4)
True if Goal is successfully applied on all matching elements of the list. The maplist family of predicates is defined as:
maplist(G, [X_11, ..., X_1n],
           [X_21, ..., X_2n],
           ...,
           [X_m1, ..., X_mn]) :-
   call(G, X_11, ..., X_m1),
   call(G, X_12, ..., X_m2),
   ...
   call(G, X_1n, ..., X_mn).

This family of predicates is deterministic iff Goal is deterministic and List1 is a proper list, i.e., a list that ends in [].

 maplist(:Goal, ?List1)
 maplist(:Goal, ?List1, ?List2)
 maplist(:Goal, ?List1, ?List2, ?List3)
 maplist(:Goal, ?List1, ?List2, ?List3, ?List4)
True if Goal is successfully applied on all matching elements of the list. The maplist family of predicates is defined as:
maplist(G, [X_11, ..., X_1n],
           [X_21, ..., X_2n],
           ...,
           [X_m1, ..., X_mn]) :-
   call(G, X_11, ..., X_m1),
   call(G, X_12, ..., X_m2),
   ...
   call(G, X_1n, ..., X_mn).

This family of predicates is deterministic iff Goal is deterministic and List1 is a proper list, i.e., a list that ends in [].

 convlist(:Goal, +ListIn, -ListOut) is det
Similar to maplist/3, but elements for which call(Goal, ElemIn, _) fails are omitted from ListOut. For example (using library(yall)):
?- convlist([X,Y]>>(integer(X), Y is X^2),
            [3, 5, foo, 2], L).
L = [9, 25, 4].
Compatibility
- Also appears in YAP library(maplist) and SICStus library(lists).
 foldl(:Goal, +List, +V0, -V)
 foldl(:Goal, +List1, +List2, +V0, -V)
 foldl(:Goal, +List1, +List2, +List3, +V0, -V)
 foldl(:Goal, +List1, +List2, +List3, +List4, +V0, -V)
Fold an ensemble of m (0 <= m <= 4) lists of length n head-to-tail ("fold-left"), using columns of m list elements as arguments for Goal. The foldl family of predicates is defined as follows, with V0 an initial value and V the final value of the folding operation:
foldl(G, [X_11, ..., X_1n],
         [X_21, ..., X_2n],
         ...,
         [X_m1, ..., X_mn], V0, V) :-
   call(G, X_11, ..., X_m1, V0, V1),
   call(G, X_12, ..., X_m2, V1, V2),
   ...
   call(G, X_1n, ..., X_mn, V<n-1>, V).

No implementation for a corresponding foldr is given. A foldr implementation would consist in first calling reverse/2 on each of the m input lists, then applying the appropriate foldl. This is actually more efficient than using a properly programmed-out recursive algorithm that cannot be tail-call optimized.

 foldl(:Goal, +List, +V0, -V)
 foldl(:Goal, +List1, +List2, +V0, -V)
 foldl(:Goal, +List1, +List2, +List3, +V0, -V)
 foldl(:Goal, +List1, +List2, +List3, +List4, +V0, -V)
Fold an ensemble of m (0 <= m <= 4) lists of length n head-to-tail ("fold-left"), using columns of m list elements as arguments for Goal. The foldl family of predicates is defined as follows, with V0 an initial value and V the final value of the folding operation:
foldl(G, [X_11, ..., X_1n],
         [X_21, ..., X_2n],
         ...,
         [X_m1, ..., X_mn], V0, V) :-
   call(G, X_11, ..., X_m1, V0, V1),
   call(G, X_12, ..., X_m2, V1, V2),
   ...
   call(G, X_1n, ..., X_mn, V<n-1>, V).

No implementation for a corresponding foldr is given. A foldr implementation would consist in first calling reverse/2 on each of the m input lists, then applying the appropriate foldl. This is actually more efficient than using a properly programmed-out recursive algorithm that cannot be tail-call optimized.

 foldl(:Goal, +List, +V0, -V)
 foldl(:Goal, +List1, +List2, +V0, -V)
 foldl(:Goal, +List1, +List2, +List3, +V0, -V)
 foldl(:Goal, +List1, +List2, +List3, +List4, +V0, -V)
Fold an ensemble of m (0 <= m <= 4) lists of length n head-to-tail ("fold-left"), using columns of m list elements as arguments for Goal. The foldl family of predicates is defined as follows, with V0 an initial value and V the final value of the folding operation:
foldl(G, [X_11, ..., X_1n],
         [X_21, ..., X_2n],
         ...,
         [X_m1, ..., X_mn], V0, V) :-
   call(G, X_11, ..., X_m1, V0, V1),
   call(G, X_12, ..., X_m2, V1, V2),
   ...
   call(G, X_1n, ..., X_mn, V<n-1>, V).

No implementation for a corresponding foldr is given. A foldr implementation would consist in first calling reverse/2 on each of the m input lists, then applying the appropriate foldl. This is actually more efficient than using a properly programmed-out recursive algorithm that cannot be tail-call optimized.

 foldl(:Goal, +List, +V0, -V)
 foldl(:Goal, +List1, +List2, +V0, -V)
 foldl(:Goal, +List1, +List2, +List3, +V0, -V)
 foldl(:Goal, +List1, +List2, +List3, +List4, +V0, -V)
Fold an ensemble of m (0 <= m <= 4) lists of length n head-to-tail ("fold-left"), using columns of m list elements as arguments for Goal. The foldl family of predicates is defined as follows, with V0 an initial value and V the final value of the folding operation:
foldl(G, [X_11, ..., X_1n],
         [X_21, ..., X_2n],
         ...,
         [X_m1, ..., X_mn], V0, V) :-
   call(G, X_11, ..., X_m1, V0, V1),
   call(G, X_12, ..., X_m2, V1, V2),
   ...
   call(G, X_1n, ..., X_mn, V<n-1>, V).

No implementation for a corresponding foldr is given. A foldr implementation would consist in first calling reverse/2 on each of the m input lists, then applying the appropriate foldl. This is actually more efficient than using a properly programmed-out recursive algorithm that cannot be tail-call optimized.

 scanl(:Goal, +List, +V0, -Values)
 scanl(:Goal, +List1, +List2, +V0, -Values)
 scanl(:Goal, +List1, +List2, +List3, +V0, -Values)
 scanl(:Goal, +List1, +List2, +List3, +List4, +V0, -Values)
Scan an ensemble of m (0 <= m <= 4) lists of length n head-to-tail ("scan-left"), using columns of m list elements as arguments for Goal. The scanl family of predicates is defined as follows, with V0 an initial value and V the final value of the scanning operation:
scanl(G, [X_11, ..., X_1n],
         [X_21, ..., X_2n],
         ...,
         [X_m1, ..., X_mn], V0, [V0, V1, ..., Vn] ) :-
   call(G, X_11, ..., X_m1, V0, V1),
   call(G, X_12, ..., X_m2, V1, V2),
   ...
   call(G, X_1n, ..., X_mn, V<n-1>, Vn).

scanl behaves like a foldl that collects the sequence of values taken on by the Vx accumulator into a list.

 scanl(:Goal, +List, +V0, -Values)
 scanl(:Goal, +List1, +List2, +V0, -Values)
 scanl(:Goal, +List1, +List2, +List3, +V0, -Values)
 scanl(:Goal, +List1, +List2, +List3, +List4, +V0, -Values)
Scan an ensemble of m (0 <= m <= 4) lists of length n head-to-tail ("scan-left"), using columns of m list elements as arguments for Goal. The scanl family of predicates is defined as follows, with V0 an initial value and V the final value of the scanning operation:
scanl(G, [X_11, ..., X_1n],
         [X_21, ..., X_2n],
         ...,
         [X_m1, ..., X_mn], V0, [V0, V1, ..., Vn] ) :-
   call(G, X_11, ..., X_m1, V0, V1),
   call(G, X_12, ..., X_m2, V1, V2),
   ...
   call(G, X_1n, ..., X_mn, V<n-1>, Vn).

scanl behaves like a foldl that collects the sequence of values taken on by the Vx accumulator into a list.

 scanl(:Goal, +List, +V0, -Values)
 scanl(:Goal, +List1, +List2, +V0, -Values)
 scanl(:Goal, +List1, +List2, +List3, +V0, -Values)
 scanl(:Goal, +List1, +List2, +List3, +List4, +V0, -Values)
Scan an ensemble of m (0 <= m <= 4) lists of length n head-to-tail ("scan-left"), using columns of m list elements as arguments for Goal. The scanl family of predicates is defined as follows, with V0 an initial value and V the final value of the scanning operation:
scanl(G, [X_11, ..., X_1n],
         [X_21, ..., X_2n],
         ...,
         [X_m1, ..., X_mn], V0, [V0, V1, ..., Vn] ) :-
   call(G, X_11, ..., X_m1, V0, V1),
   call(G, X_12, ..., X_m2, V1, V2),
   ...
   call(G, X_1n, ..., X_mn, V<n-1>, Vn).

scanl behaves like a foldl that collects the sequence of values taken on by the Vx accumulator into a list.

 scanl(:Goal, +List, +V0, -Values)
 scanl(:Goal, +List1, +List2, +V0, -Values)
 scanl(:Goal, +List1, +List2, +List3, +V0, -Values)
 scanl(:Goal, +List1, +List2, +List3, +List4, +V0, -Values)
Scan an ensemble of m (0 <= m <= 4) lists of length n head-to-tail ("scan-left"), using columns of m list elements as arguments for Goal. The scanl family of predicates is defined as follows, with V0 an initial value and V the final value of the scanning operation:
scanl(G, [X_11, ..., X_1n],
         [X_21, ..., X_2n],
         ...,
         [X_m1, ..., X_mn], V0, [V0, V1, ..., Vn] ) :-
   call(G, X_11, ..., X_m1, V0, V1),
   call(G, X_12, ..., X_m2, V1, V2),
   ...
   call(G, X_1n, ..., X_mn, V<n-1>, Vn).

scanl behaves like a foldl that collects the sequence of values taken on by the Vx accumulator into a list.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 call_det_when_ground(Arg1, Arg2)
 call_if_ground(Arg1, Arg2)
 call_when_ground(Arg1, Arg2)
 true(Arg1, Arg2)
 true(Arg1, Arg2, Arg3)