Merge pull request #740 from triska/indexing
small documentation improvements related to the new indexing strategy
This commit is contained in:
15
README.md
15
README.md
@@ -233,24 +233,23 @@ in all clauses of a predicate's definition. We call this strategy
|
|||||||
first *instantiated* argument indexing.
|
first *instantiated* argument indexing.
|
||||||
|
|
||||||
A key motivation for first instantiated argument indexing is to enable
|
A key motivation for first instantiated argument indexing is to enable
|
||||||
indexing for meta-predicates such as `maplist/N` and `foldl/N`, where
|
indexing for meta-predicates such as `maplist/N` and `foldl/N`, whose
|
||||||
the first argument is a goal or partial goal that is a variable in the
|
first argument is a partial goal that is a variable in the definition
|
||||||
definition of these predicates and therefore cannot be used for
|
of these predicates and therefore cannot be used for indexing.
|
||||||
indexing.
|
|
||||||
|
|
||||||
For example, a natural definiton of `maplist/2` reads:
|
For example, a natural definiton of `maplist/2` reads:
|
||||||
|
|
||||||
```
|
```
|
||||||
maplist(_, []).
|
maplist(_, []).
|
||||||
maplist(Goal, [L|Ls]) :-
|
maplist(Goal_1, [L|Ls]) :-
|
||||||
call(Goal, L),
|
call(Goal_1, L),
|
||||||
maplist(Goal, Ls).
|
maplist(Goal_1, Ls).
|
||||||
```
|
```
|
||||||
|
|
||||||
In this case, first instantianted argument indexing automatically uses
|
In this case, first instantianted argument indexing automatically uses
|
||||||
the *second* argument for indexing, and thus prevents choicepoints for
|
the *second* argument for indexing, and thus prevents choicepoints for
|
||||||
calls with lists of fixed lengths (and deterministic goals).
|
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.
|
needed to benefit from indexing in such cases.
|
||||||
|
|
||||||
Conventional first argument indexing naturally arises as a
|
Conventional first argument indexing naturally arises as a
|
||||||
|
|||||||
Reference in New Issue
Block a user