File "hiord"
This file introduces higher order logic programming to the
Dogelog Player Prolog system, in that we support the predicates
call/n. The predicates are not realized inside the Novacore, but
have to be explicitly requested through this file. The predicates
call/n are provided for the arities n = 2..8, the minimum required
by the ISO core Prolog standard.
The predicates maplist/n and foldl/n apply a closure on the
members of a list. Thus freeing the end-user from writing the
boiler plate code of a loop. This allows for set oriented
processing of lists without the need for backtracking. The
drawback is increased use of memory, since the lists are
materialized.
The following hiord predicates are provided:
- numbervars(X, N, M):
- The predicate succeeds in M with the next index after
numbering all variables in X starting with index N.
- unnumbervars(S, N, T):
- The predicate succeeds in T with a copy of S with the
numbering greater or equal than N replaced by variables.
- maxvars(T, M):
- The predicate succeeds in M with the max numbering of the
term X.
- free_variables(Q, L, G): [ISO 7.1.1.4]
- The predicate succeeds in L with the free variabes of Q and in
G with the quantifier free of Q.
- call(F, A1, .., An): [Corr.2 8.15.4.4]
- The predicate succeeds in calling the goal which results from
appending the arguments A1, .., An to the callable F.
- maplist(C, L1, .., Ln): [N235 7.4]
- The predicate succeeds whenever the closure C can be applied
to each of the joint elements X1, .., Xn in the lists L1, .. Ln.
- foldl(C, L1, .., Ln, I, O):
- The predicate succeeds in O with the closure C chained through
the elements X1, .., Xn of the lists L1, .. Ln starting with I.