Replies: 3 comments 1 reply
-
On the toplevel, you can easily get this by pressing ?- length(Path, L), from_to_path(a, g, Path). Path = "acg", L = 3 ; ... . Note that using the $ scryer-prolog -g run,halt your_file.pl It is unusual for Prolog code to invoke |
Beta Was this translation helpful? Give feedback.
-
One benefit of iterative deepening is you are changing your search strategy to find solutions with shorter lengths first. However it is the nature of Prolog to keep searching for alternative solutions assuming you requested it to do so from the top-level. I have seen previous code use the once(Goal) predicate to force only a single solution. I'm not sure if that is considered "best practice" or if there are alternate methods. |
Beta Was this translation helpful? Give feedback.
-
I have tried using |
Beta Was this translation helpful? Give feedback.
-
I wrote a simple program that searches a tree in order to learn about iterative deepening.
It finds a path from one tree node to another.
It works correctly, but once a solution is found, it evaluates the rest of the nodes in the tree unnecessarily.
See https://github.com/mvolkmann/prolog-examples/blob/main/search.pl#L71.
Is there an easy way to make it stop once a solution is found?
Beta Was this translation helpful? Give feedback.
All reactions