Subject: Re: [SWIPL] indexing clarification

From: Jan Wielemaker <[email-masked]>
Date: Thu, 24 May 2001 22:49:35 +0200

> I would like some clarification on indexing.  Below I have quoted a 
> sentence from the documentation for 'index':
> 
> "Only atoms, integers and functors (e.g. name and arity of a term) are 
> considered."
> 
> What is meant by a 'functor'?  I assume this means that during indexing 
> grocery/6 is treated as a 'functor' and not as a term with functor '/' and 
> arity 2.  ie.  /(grocery,6)

No.  It means that grocery/6 is indexed as an instance of //2.  After
this mail I rephrased the documentation to:

``Only atoms, integers and compound terms are considered. Compound
terms are indexed on the combination of their name and arity. Indexing
is very useful for predicates with many clauses representing facts.''

> So does that mean that the following can be indexed on the first argument?
> 
> tables(grocery/6, A, B, tables(A, C, D), tables(B, C, D)).

If, as I assume you do, all first argument are different but of the form
name/arity, the answer is no.

> Also, do other prolog implementations do the same?

*What* is indexed is common practice in the Prolog world.  *How* is
an entirely different issue.  If you want to index odd things, have
a look at hash_term/2.

	Regards --- Jan