From pascal@rz.hu-berlin.de  Fri Jan  7 13:10:26 2000
Received: from suncom.rz.hu-berlin.de (suncom.rz.hu-berlin.de [141.20.1.31])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id NAA05098
	for <prolog@swi.psy.uva.nl>; Fri, 7 Jan 2000 13:10:25 +0100 (MET)
Received: from localhost.rz.hu-berlin.de (ppp196-103.rz.hu-berlin.de [141.20.196.103])
	by suncom.rz.hu-berlin.de (8.9.3/8.9.3) with ESMTP id NAA08896
	for <prolog@swi.psy.uva.nl>; Fri, 7 Jan 2000 13:10:28 +0100 (MET)
Received: (from pascal@localhost)
	by localhost (8.8.8/8.8.8/Debian/GNU) id NAA02052;
	Fri, 7 Jan 2000 13:11:08 +0100
Date: Fri, 7 Jan 2000 12:11:07 +0000 (GMT)
From: Pascal Vaillant <Pascal.Vaillant@rz.hu-berlin.de>
To: Prolog Mailing List <prolog@swi.psy.uva.nl>
Subject: RE: I am having trouble writing replace/4 
In-Reply-To: <LFEJKFIDOJEOIHAFBNBFIEBBCCAA.rhoekstr@wins.uva.nl>
Message-ID: <Pine.LNX.4.05.10001071209160.2036-100000@ppp196-103.rz.hu-berlin.de>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII


> replace_list([],[],List,List).
> replace_list([HReplacant|TReplacant],[HReplacer|TReplacer],List,NewList):-
> 	replace(HReplacant,HReplacer,List,IList),
> 	replace_list(TReplacant,TReplacer,IList,NewList).
> 
> replace(_,_,[],[]).
> replace(HReplacant,HReplacer,[HReplacant|Tail],[HReplacer|NewTail]):-
> 	replace(HReplacant,HReplacer,Tail,NewTail).
> replace(HReplacant,HReplacer,[Head|Tail],[Head|NewTail]):-
> 	replace(HReplacant,HReplacer,Tail,NewTail).
> 
> This algorithm takes less steps (trace it to find out).
> 

Right, but it doesn't solve Doug's problem (he does not want
HReplacant [A in his version] to be unified with some element
of the Replacer list).

Groetjes,

Pascal


