To begin with - this is coursework so I can't post code. This is more about how prolog outputs its answers rather than "is my code right"?
I'm creating a predicate that returns all simple paths between a graph, given a list of edges.
For example, paths(a, X)
will return all the possible paths that start with a
.
Say my KB is: edge(a,b). edge(b,c). edge(c,d). edge(d,f).
Then I should get X = [[a], [a,b], [a,b,c], [a,b,c,d], [a,b,c,d,f]]
- and I do. The problem is, if the output is longer, then it doesn't show every possible output - the output is shown as follows:
Paths = [[b],[b,c],[b,c,d],[b,c,d,a],[b,c,d,e],[b,c,d,f],[b,c,d,f|...]] ?
y
Is there any way I can make my interpreter explicitly show everything? The last list is incomplete - it should show [b,c,d,f,g]. For the record, I'm using SICSTUS
This is just a printing habit of prolog when lists get long, it only prints some prefix. try adding a print(Paths)
goal. That should show you the actual, non-truncated, list.