From a-doug@microsoft.com  Fri Jan  7 05:19:07 2000
Received: from mail1.microsoft.com (mail1.microsoft.com [131.107.3.125])
	by swi.psy.uva.nl (8.9.3/8.9.3) with SMTP id FAA24109
	for <prolog@swi.psy.uva.nl>; Fri, 7 Jan 2000 05:19:06 +0100 (MET)
Received: from 157.54.9.101 by mail1.microsoft.com (InterScan E-Mail VirusWall NT); Thu, 06 Jan 2000 20:18:37 -0800 (Pacific Standard Time)
Received: by INET-IMC-01 with Internet Mail Service (5.5.2650.21)
	id <CM1M757M>; Thu, 6 Jan 2000 20:18:36 -0800
Message-ID: <E713F2760348D211A9B600805F6FA1AB03559908@RED-MSG-09.itg-messaging.redmond.corp.microsoft.com>
From: "Douglas Miles (Volt Computer)" <a-doug@microsoft.com>
To: "'prolog@swi.psy.uva.nl'" <prolog@swi.psy.uva.nl>
Subject: I am having trouble writing replace/4 
Date: Thu, 6 Jan 2000 20:18:35 -0800 
X-Mailer: Internet Mail Service (5.5.2650.21)


replaceList([],[],NothingToDo,NothingToDo):-!.
replaceList([HeadBefore|TailBefore],[HeadAfter|TailAfter],Start,End):-!,
        replace(HeadBefore,HeadAfter,Start,Midde),
        replaceList(TailBefore,TailAfter,Middle,End).

replace(_, _, [], []):-!.
replace(A, B, [A|L], [B|R]) :- !,    replace(A, B, L, R).
replace(A, B, [C|L], [C|R]) :-   replace(A, B, L, R).

here is my trouble..

?- replaceList([a,b],[A,B],[1,2,3,a,b,c,x,y,z],O).
A = b
B = _G422
O = [1, 2, 3, _G422, _G422, c, x, y, z]
yes

I guess the real question is how can I write a replace only once..  or
rewrite replaceList?

I want it to do this...

?- replaceList([a,b],[A,B],[1,2,3,a,b,c,x,y,z],O).
A = _G421
B = _G422
O = [1, 2, 3, _G421, _G422, c, x, y, z]
yes

is copy_term/2 the key? I have tried a few tricks..
or maybe numbervars can help?

Any Suggestions?

Thank you, 
	Douglas Miles a-doug@microsoft.com	
	<goofy-ms.gif>


