Prolog-style unification?
Simon Burton
simonb at webone.com.au
Sat Jun 7 22:28:17 EDT 2003
On Sat, 07 Jun 2003 14:38:40 -0600, junk wrote:
> Hi Robert,
>
> I am working on a Master's Thesis currently where this issue is of
> concern. I would also like to know if there is such a module.
>
> In the mean time, I have written my own module which does a pretty good
> job of simulating Prolog style calls. Here is what my syntax looks like
> right now:
>
> import logic
> Father = logic.Fact()
> Father("Seth","Alex")
> Father("James","Seth")
> X = logic.LogicalVariable()
> Y = logic.LgocialVariable()
too verbose for me. howbout just Var ?
> while Father(X,Y):
> print X, Y
Know about iterators?
i'd like to see
for x,y in Father():
print x, y
are you trying too hard to adhere to prolog syntax maybe?
>
> print "--------------"
>
> Grandfather = logic.Fact()
> Grandfather(Grandfather.Grandfather, Grandfather.Grandson) (
> Father(Grandfather.Grandfather, Grandfather.Son)
> Father(Grandfather.Son, Grandfather.Grandson))
does this use __getattr__ hooks? otherwise where does the attributes of
Grandfather come from?
>
> while Grandfather(X,Y):
> print X,Y
>
>
> The output of this is:
>
> James Seth
> Seth Alex
> ------------------
> James Alex
>
> I'm still tracking down bugs all the time, but it's getting pretty good.
>
> Would you PLEASE let me know what you think?
>
> -- Seth James Nielson
Excellent; i'd like to see more logic for python stuff.
Please post your code!
Simon Burton.
More information about the Python-list
mailing list