Reputation: 23
I have an list and I want to check if it is ordered. Can somebody point out my error?
Thanks
taxinomemene([]).
taxinomemene([element1,element2|Tail]):-
stoixio1>stoixio12,
taxinomemene([stoixio2|Tail]).
Upvotes: 1
Views: 2597
Reputation: 842
What if you have a singleton list and what are stoixio1 and stoixio12? the condition should be in terms of element1 and element2
is_sorted([]).
is_sorted([_]).
is_sorted([X,Y|T]) :-
X=<Y,
is_sorted([Y|T]).
Upvotes: 2