Subject: RE: I am having trouble writing replace/4

From: Pascal Vaillant <[email-masked]>
Date: Fri, 7 Jan 2000 12:11:07 +0000 (GMT)

> 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