prolog check if a list is in ascending order -
i have list , want check if ordered. can point out error?
thanks
taxinomemene([]). taxinomemene([element1,element2|tail]):- stoixio1>stoixio12, taxinomemene([stoixio2|tail]).
what if have singleton list , stoixio1 , stoixio12? condition should in terms of element1 , element2
is_sorted([]). is_sorted([_]). is_sorted([x,y|t]) :- x=<y, is_sorted([y|t]).
Comments
Post a Comment