Hello fellow logicians! I'm trying to translate the following prolog problem to core.logic:
>From http://tjeyamy.blogspot.com/2011/02/path-finding-in-prolog.html edge(1,2). edge(1,4). edge(2,4). edge(3,6). edge(3,7). edge(4,3). edge(4,5). edge(5,6). edge(5,7). edge(6,5). edge(7,5). edge(8,6). edge(8,7). path(X,Y,[X,Y]):- edge(X,Y). path(X,Y,[X|Xs]):- edge(X,W), path(W,Y,Xs). path(1, 7, P). %Results Z = [1, 2, 4, 3, 6, 5, 7]; Z = [1, 2, 4, 3, 6, 5, 6, 5, 7]; Here are a couple of my own attempts using core.logic: (defrel edge x y) (fact edge 1 2) (fact edge 1 4) (fact edge 2 4) (fact edge 3 6) (fact edge 3 7) (fact edge 4 3) (fact edge 4 5) (fact edge 5 6) (fact edge 5 7) (fact edge 6 5) (fact edge 7 5) (fact edge 8 6) (fact edge 8 7) (defn path2 [x y p] (conde [(fresh [] (conso x [y] p) (edge x y))] [(fresh [w r] (conso x r p) (edge x w) (path2 w y r))])) (defne path3 [x y p] ([ x y [x . [y] ] ] (edge x y)) ([ x y [x . r] ] (fresh [w] (edge x w) (path3 w y r)))) Hopefully I've understood enough that path3 is just the pattern matching version of path2 ;-) What happens, though, is that both of these end up in an infinite loop. Any hints about what I'm doing wrong? I'm sure I'm missing something fundamental here. Is there some sort of debugging I can do to figure this out? Or some way to trace execution? Thanks for any help! Cheers, Craig -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.