简体   繁体   English

序言检查列表是否按升序排列

[英]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? 如果您有单例列表,什么是stoixio1和stoixio12? the condition should be in terms of element1 and element2 条件应根据element1和element2

is_sorted([]).
is_sorted([_]).
is_sorted([X,Y|T]) :-
   X=<Y,
   is_sorted([Y|T]).

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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