3 ms·
I am quite pleased with the ability to easily use prolog from within python and vice versa. It makes it now one of the easiest and most expressive solvers to p
by philzook 2y ago
I am quite pleased with the ability to easily use prolog from within python and vice versa. It makes it now one of the easiest and most expressive solvers to plug into for my tastes. I'm starting to accumulate useful solvers here https://github.com/philzook58/prologsolvers/tree/164297d87f67202e5906d03a5b07d6ff7ce75ef9 https://github.com/philzook58/prologsolvers/tree/164297d87f6...
You need to install swi prolog https://www.swi-prolog.org/download/stable https://www.swi-prolog.org/download/stable and pip install janus_swi
A simple example to get started:
https://www.swi-prolog.org/pldoc/doc_for?object=section(%27packages/janus.html%27) https://www.swi-prolog.org/pldoc/doc_for?object=section(%27p...
import janus_swi as janus
janus.consult("path", """
edge(a,b).
edge(b,c).
edge(c,d).
:- table path/2.
path(X,Y) :- edge(X,Y).
path(X,Y) :- edge(X,Z), path(Z,Y).
""")
list(janus.query("path(a,Y)."))