From jan@swi.psy.uva.nl Thu May 24 22:49:35 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f4OKnZ301861;
	Thu, 24 May 2001 22:49:35 +0200 (MET DST)
Received: (from jan@localhost)
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f4OKnZ213439;
	Thu, 24 May 2001 22:49:35 +0200
Date: Thu, 24 May 2001 22:49:35 +0200
Message-Id: <200105242049.f4OKnZ213439@gollem.swi.psy.uva.nl>
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Subject: Re: [SWIPL] indexing clarification
To: prolog@swi.psy.uva.nl, prolog-request@swi.psy.uva.nl
Phone: +31 - 20 - 525 6121

> 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

