Deleting elments of a list which are in it more than once

From: Christian Bruckhoff (brchrist_at_uni-koblenz.de)
Date: 02/15/05


Date: Tue, 15 Feb 2005 15:34:44 +0100

Hi.
I wanted to write a prolog programm which checks a given list of elements,
which are in it mor than once.
If an element is in twice ore more, all same elements following the first
one should be deketed.

For example:
Given list [a,b,a,a,r,s,z,s,b,t,s,b]
Output list [a,b,r,s,z,t]

My idea was he following:
scan([],[]).
scan([A|Rest],Neu):-member(A, Rest),delete(Rest,A,Neu1),append([A], Neu1,
Neu), scan(Rest,Neu).

But there must be a recursive call of scan for the rest of the list. And
there is my Problem: I can't find the rigth way to call it recursiely. :'(

Anyone has an idea?

-- 
cya
Christian Bruckhoff 


Relevant Pages