From nicos@soi.city.ac.uk Thu May 31 20:23:00 2001
Received: from altair.soi.city.ac.uk (IDENT:root@altair.soi.city.ac.uk [138.40.91.7])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f4VIMx304801
	for <prolog@swi.psy.uva.nl>; Thu, 31 May 2001 20:23:00 +0200 (MET DST)
Received: from localhost (nicos@localhost)
	by altair.soi.city.ac.uk (8.11.0/8.9.1) with ESMTP id f4VIMrH17706;
	Thu, 31 May 2001 19:22:53 +0100
Date: Thu, 31 May 2001 19:22:53 +0100 (BST)
From: Nicos Angelopoulos <nicos@soi.city.ac.uk>
To: Partsakoulakis Ioannis <jpar@aegean.gr>
cc: "'prolog@swi.psy.uva.nl'" <prolog@swi.psy.uva.nl>
Subject: Re: [SWIPL] another question
In-Reply-To: <81FBBA8C21B9D311A6E500508B6144AA1201AC@eupalinos.aegean.gr>
Message-ID: <Pine.LNX.4.21.0105311915300.14724-100000@altair.soi.city.ac.uk>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

On Thu, 31 May 2001, Partsakoulakis Ioannis wrote:

> I want to ask how can I define a predicate
> a(+Term,+ListOfTerms,-ListOfInstances) such that if term Term is unifiable
> with a term in ListOfTemrs then ListOfInstances will contain the
> correspinding instance of Term. For example if ask
> 
> ?- a( p(1,X), [p(Y,2),p(2,1),p(1,3)], L ).
> 
> I want to take
> 
> L = [p(1,2),p(1,3)].
> 
> Can somebody help me?
> 
> Thanks,
> 
> Yannis.
> 

one way to do this is by using the  copy_term/2 built-in

a/3 (or unifies_with_sieve/3, i ld also change the order of 
the first two arguments) should go down +ListOfTerms
each time making a fresh copy of +Term, then performing
unification on the fresh copy, (if unification is possible
then store fresh copy in -ListOfInstances, otherwise skip it)

nicos.  

