Prolog-style unification?
Nielson Family
junk at geekabytes.net
Mon Jun 9 13:15:35 EDT 2003
Steven Taschuk wrote:
>Quoth Simon Burton:
>
>
>>On Sat, 07 Jun 2003 14:38:40 -0600, junk wrote:
>>
>>
> [...]
>
>
>>>while Father(X,Y):
>>> print X, Y
>>>
>>>
>>Know about iterators?
>>
>>i'd like to see
>>for x,y in Father():
>> print x, y
>>
>>
>
>It's not clear how you'd do any more complex query with such a
>scheme. What if you want grandfathers of Seth, for example? The
>original allows for the possibility of something like
>
> Father(X, Y) & Father(Y, "Seth")
>
>for example.
>
>
>
Yes, you can do this. I am working to make the syntax exactly like prolog.
So,
while Grandfather(X,"Seth"):
print X
is what you would do.
Right now the syntax works like this:
you define facts by using values (non-logic variables):
father("Seth","Alex")
father("Seth","Drystan") ## mykids ;)
and you query by using a logic variable
father(X,"Alex")
father(X,Y)
AND, you can query strings by setting a query mode
father.setMode(logc.QUERY)
father("Seth","Alex") #returns true.
This extends to inferences (like Grandfather).
I'm currently working on making facts and inferences work together. For
example, you could declare one person to be another's grandfather or via
inference.
As I've said in other emails, the pseudo syntax is changing constantly
as I try to figure out the best way to do it.
-- Seth
More information about the Python-list
mailing list