I have rewritten the last part, it does seem to work now:
most_points(Most):- most_points(_, Most),!. %hides most_points\2, cuts duplicates
most_points(Old, New):- more_points(Current, Old), most_points(Current, New).
most_points(Old, New):- \+ more_points(_, Old), New = Old. %the line above...
Hi, I'm new to prolog. I have folowing predicated in my program:
points(bob, 3).
points(ted, 10).
points(tom, 7).
points(ben, 5).
How do I find out who has the most points?
I don't know how to make Prolog iterate through all points() predicates and remember the highest value. Iterating...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.