Subject: Re: [SWIPL] another question

From: Nicos Angelopoulos <[email-masked]>
Date: Thu, 31 May 2001 19:22:53 +0100 (BST)

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.