RosettaCodeData/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-3.pro

7 lines
172 B
Prolog
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
member1(X,[H|_]) :- X==H,!.
2015-02-20 00:35:01 -05:00
member1(X,[_|T]) :- member1(X,T).
2013-04-10 23:57:08 -07:00
distinct([],[]).
distinct([H|T],C) :- member1(H,T),!, distinct(T,C).
distinct([H|T],[H|C]) :- distinct(T,C).