I'm testing out graph-searching for paths in prolog using information from https://www.irit.fr/~Jerome.Mengin/teaching/prolog/prolog-search_a4.pdf and ran into some issues with writing from recursive func.
My code can find all possible paths from node1 to node2 however the results(paths) are printed out in reverse order.
edge(a, c).
edge(a, d).
edge(c, e).
edge(e, f).
edge(d, f).
paths(Curr,Stop) :-
Curr==Stop -> write(Curr);
edge(Curr,Next),
paths(Next,Stop),
write(Curr).
For example paths(a,f) yields: feca true ; fda true.
However I want the results in the correct order acef and adf written without the use of lists.