Prolog finding the largest integer in a list from the tail
I need to find the largest integer in a list from the head of a list and alternatively from the tail. I have already written a program that can find the largest from the head now I need some help to do it from the tail. Here is what I have so far: largest([X],X). largest([X|Xs],X) :- largest(Xs,Y), X>=Y. largest([X|Xs],N) :- largest(Xs,N), N>X. Keep in mind that this finds the largest integer from the head, and I need it to work from the tail. Thanks for the help. false Hold on for a second! Before you continue, first measure the time your predicate takes! ?- length(J,I), I>10, append(J,[2],L)