remove_duplicates should keep order

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@186 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2001-11-19 17:53:19 +00:00
parent 5ab74e898a
commit 1df8d979cd
1 changed files with 4 additions and 2 deletions

View File

@ -222,8 +222,10 @@ prefix([Elem | Rest_of_part], [Elem | Rest_of_whole]) :-
% removes duplicated elements from List. Beware: if the List has
% non-ground elements, the result may surprise you.
remove_duplicates(List, Pruned) :-
sort(List, Pruned).
remove_duplicates([], []).
remove_duplicates([Elem|L], [Elem|NL]) :-
delete(L, Elem, Temp),
remove_duplicates(Temp, NL).
% reverse(List, Reversed)
% is true when List and Reversed are lists with the same elements