Merge pull request #740 from triska/indexing

small documentation improvements related to the new indexing strategy
This commit is contained in:
Mark Thom
2020-12-22 15:39:17 -07:00
committed by GitHub

View File

@@ -233,24 +233,23 @@ in all clauses of a predicate's definition. We call this strategy
first *instantiated* argument indexing.
A key motivation for first instantiated argument indexing is to enable
indexing for meta-predicates such as `maplist/N` and `foldl/N`, where
the first argument is a goal or partial goal that is a variable in the
definition of these predicates and therefore cannot be used for
indexing.
indexing for meta-predicates such as `maplist/N` and `foldl/N`, whose
first argument is a partial goal that is a variable in the definition
of these predicates and therefore cannot be used for indexing.
For example, a natural definiton of `maplist/2` reads:
```
maplist(_, []).
maplist(Goal, [L|Ls]) :-
call(Goal, L),
maplist(Goal, Ls).
maplist(Goal_1, [L|Ls]) :-
call(Goal_1, L),
maplist(Goal_1, Ls).
```
In this case, first instantianted argument indexing automatically uses
the *second* argument for indexing, and thus prevents choicepoints for
calls with lists of fixed lengths (and deterministic goals).
Conveniently, no auxiliary predicates with reorderd arguments are
Conveniently, no auxiliary predicates with reordered arguments are
needed to benefit from indexing in such cases.
Conventional first argument indexing naturally arises as a