From 1df8d979cdcad37840041b376fc781e12b171729 Mon Sep 17 00:00:00 2001 From: vsc Date: Mon, 19 Nov 2001 17:53:19 +0000 Subject: [PATCH] remove_duplicates should keep order git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@186 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- library/lists.yap | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/lists.yap b/library/lists.yap index 2d7fb8719..daf0ef7aa 100644 --- a/library/lists.yap +++ b/library/lists.yap @@ -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