I have a set of companies in rank order. I want my rule to check if the companies in a specified list are in rank order, and for the rule to recur until all companies in the list have been checked.
I currently have the following:
isOrder([]).
isOrder([COM1,COM2|T]) :-
rank(COM1,D), rank(COM2,E),
D<E,
print("in order"),
isOrder([COM2|T]).
However, this does not seem to work. Sometimes, the recursion goes on forever without ending, and sometimes the recursion doesn't work at all. This is when I vary the code to try and get the correct answer.
Can anybody help me? I have just started Prolog and my understanding of it is severely limited. Any help would be greatly appreciated.