Skip to content
Snippets Groups Projects
Commit 978c766d authored by Marius Frinken's avatar Marius Frinken
Browse files

improved tips.pl

parent 644cf7a3
Branches
No related tags found
No related merge requests found
...@@ -20,8 +20,20 @@ tag_and_process(List):- ...@@ -20,8 +20,20 @@ tag_and_process(List):-
%Prolog offers multiple ways of sorting, this is one %Prolog offers multiple ways of sorting, this is one
% will delete duplicates
% comp_triples(Delta, (C1,_,_),(C2,_,_)):-
% compare(Delta,C1,C2).
%more complicated version that allows for equal values and does not offer faulty backtracking
comp_triples(Delta, (C1,_,_),(C2,_,_)):- comp_triples(Delta, (C1,_,_),(C2,_,_)):-
compare(Delta,C1,C2). (
C1==C2 -> %if C1 has the same value as C2 , == does not unify
Delta = >;
compare(Delta,C1,C2)
).
% line 31 is a "dirty" hack, if C1 equals C2 we still answer > "greater"
% else, we use the built-in compare in line 32
my_sort(ListOfTriples, SortedListOfTriples):- my_sort(ListOfTriples, SortedListOfTriples):-
predsort(comp_triples,ListOfTriples,SortedListOfTriples). predsort(comp_triples,ListOfTriples,SortedListOfTriples).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment