I would like to develop a function that evaluates a list and finds the minimum of it. I have done:
minimum([X],X).
minimum([X|Y],N) :- minimum(X,N), X < N.
minimum([X|Y],N) :- minimum(Y,N), X > N.
Buut it seems that the second and third rule are wrong because it says false.
I thought it was because of I was recursively calling with minimum(X,N) and it makes a mistake so I checked with:
minimum([X],X).
minimum([X|Y],N) :- minimum(X,X), X < N.
minimum([X|Y],N) :- minimum(Y,Y), X > N.
But it saays the same. Somebody could explain me how this behaves and give me a clue about where I could fix this! Thank you for your time.