mmxgn
unread,Sep 9, 2010, 7:15:06 AM9/9/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pyswip
Hello,
I just explored pyswip and I think it's going to help me a lot.
One question is:
I have the following prolog code for addition:
{{{
plus(z, N, N).
plus(s(Mn), N, s(Pn)) :- plus(Mn, N, Pn).
s(N).
}}}
and the following pyswip equivalent
{{{
from pyswip import Prolog
prolog = Prolog()
prolog.assertz("plus(z, N, N)");
prolog.assertz("plus(s(Mn), N, s(Pn)) :- plus(Mn, N, Pn)")
prolog.assertz("s(N)")
}}}
When I query swipl on the first with
{{{
plus(s(z), s(z), X).
}}}
It gives me that X = s(s(z)) which is the correct answer.
When on the other hand I try in python:
{{{
print list(prolog.query("plus(s(z),s(z),X)"))
}}}
It prints:
[{'X': 'Functor5267596'}]
instead of s(s(z)).
Is there a way to make it show s(s(z)) instead of the string object
above? Or have I got something wrong?