I know how to iterate over lists in Prolog to find the maximum, but what if each thing is a separate clause? For example if I had a bunch of felines and their ages, how would I find the oldest kitty?
cat(sassy, 5).
cat(misty, 3).
cat(princess, 2).
My first thought was "hmm, the oldest cat is the one for which no older exists". But I couldn t really translate that well to prolog.
oldest(X) :- cat(X, AgeX), cat(Y, AgeY), X = Y, + AgeX < AgeY, print(Y).
This still errorenously matches "misty". What s the proper way to do this? Is there some way to more directly just iterate over the ages to choose max?