I have predicate, that enumerates through backtracking list of values. I want to find highest value from this list.
For example:
ranked_move(X,Y,R) :- between(0,10,Y), between(0,10,X), rank_move(X,Y,R).
top_move(X,Y) :- % X, Y for highest R
Right now, I have it solved by using findall and custom predicate that goes through the list and remembers highest value it comes across. But I would like to know if there is way to do it without first turning the moves into a list. Eg. do the picking predicate directly on ranked_move.
I know about https://stackoverflow.com/questions/1701693/max-out-of-values-defined-by-prolog-clauses . I haven't tried it, but I assume Prolog is not going to go through the predicates efficiently.