Reaching end of list in prolog
问题 I've been given the question: Define a predicate ordered/1, which checks if a list of integers is correctly in ascending order. For example, the goal ordered([1,3,7,11]) should succeed, as should the goal ordered([1,3,3,7]) , whereas the goal ordered([1,7,3,9]) should fail. So far I have this: ordered([]). ordered([N, M|Ns]):- append(M, Ns, Tail), ordered(Tail), N =< M. But it fails on every list. I have deduced that the reason it fails is because it reaches the end number in the list then