Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
teaching
AI
Commits
978c766d
Commit
978c766d
authored
Nov 15, 2018
by
Marius Frinken
Browse files
improved tips.pl
parent
644cf7a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Marius/uebung03/tips.pl
View file @
978c766d
...
...
@@ -20,8 +20,20 @@ tag_and_process(List):-
%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
,
_
,
_
)):-
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
):-
predsort
(
comp_triples
,
ListOfTriples
,
SortedListOfTriples
).
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment