简体   繁体   中英

prolog check if a list is in ascending order

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]).

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]).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM