How To Get Functor String In Prolog Using Pyswip
I develop python app which connect to Prolog via pyswip. The following is an example of Prolog part that I executed. init( Board) :- Board = b(n,x,n,x,n,x,n,x,x,n,x,n,x,n,x,n,n,x
Solution 1:
I found my own solution. I import Functor, Variable, Query
from pyswip importProlog, Functor, Variable, Query
To get the functor value, I use
init = Functor("init", 1)
B = Variable()
soln = Query(init(B))
while soln.nextSolution():
b64 = B.get_value()
self.Board_pl = "b("for i inrange (0, 64):
self.Board_pl += (str(b64.args[i]) + ",")
self.Board_pl += (str(b64.args[63]) + ")")
print(Board)
Then, the program will print
b(n,x,n,x,n,x,n,x,x,n,x,n,x,n,x,n,n,x,n,x,n,x,n,x,e,n,e,n,e,n,e,n,n,e,n,e,n,e,n,e,o,n,o,n,o,n,o,n,n,o,n,o,n,o,n,o,o,n,o,n,o,n,o,n)
Post a Comment for "How To Get Functor String In Prolog Using Pyswip"