Indexing Directives
The compiler usually generates an index on the principal functor of the first
argument of a predicate.
The user may direct the compiler to generate an
index on any other argument by means of an indexing directive.
This is of the form
:- index(Pred, Arity, IndexArg)
index/3 (D)
indicating that an index should be created on the
argument of the predicate Pred/Arity.
All of the values Pred, Arity and IndexArg
should be bound in the directive:
Pred should be an atom, Arity a nonnegative integer, and
IndexArg an integer between 0 and Arity.
If IndexArg is 0, then no index is created for that predicate.
As an example, if we wished to create an index on the third argument of a 5-ary
predicate foo, the compiler directive would be
:- index(foo, 5, 3).
An index directive may be placed anywhere in the file containing the
predicate it refers to.