hill(+IntList) succeeds if IntList consists of monotonically increasing integers followed by monotonically decreasing integers. For example, [1,2,5,8,11,6,3,-1] is a hill, but [1,2,5,8,11,6,9,3,-1] and [1,2,3,4,5,6] are not hills. You may assume that IntList contains only integers.
This is what i have done so far.
hill(List) :-
increasing(List), decreasing(List).
increasing([H|Tail]) :-
sm(H,Tail),
increasing(Tail).
increasing([]).
decreasing([H|Tail]) :-
gr(H,Tail),
decreasing(Tail).
decreasing([]).
hill([]).
gr(X,[H|Tail]) :- X>H.
gr(X,[]).
sm(X,[H|Tail]) :- X<H.
sm(X,[]).
But this doesnt work. The logic is : A list of numbers is hill IF it s increasing and then decreasing. How do i say that? This one does increasing and decreasing. which no list is both increasing and decreasing.
Any ideas?