Is it possible to have an "or" without splitting the statement?

40 views
Skip to first unread message

Ido Carmi

unread,
Nov 2, 2016, 2:34:33 PM11/2/16
to pyDatalog
Say I have this simple program:

pyDatalog.create_terms('aa,cc,Y,Z')

+ aa(11)
+ aa(40)
+ aa(112)

cc
(Z) <= aa(Z) & (Z > 50)
cc
(Z) <= aa(Z) & (Z  < 20)

print pyDatalog.ask('cc(Y)')

I get:
set([(112,), (11,)])

(Which is what I expect to get).

My question is, can I combine the two lines:

cc(Z) <= aa(Z) & (Z > 50)
cc
(Z) <= aa(Z) & (Z  < 20)


Into a single line, something like:
cc(Z) <= aa(Z) & ((Z > 50) or ( Z < 20 ))

I get an error:
pyDatalog.util.DatalogError: Error: left hand side of comparison must be bound: >/2

Am I trying to achieve the impossible or am I missing something obvious? I know that in Prolog it's possible to do something like that using the ';' syntax...

Thanks!



Pierre Carbonnelle

unread,
Nov 2, 2016, 5:10:03 PM11/2/16
to pyDatalog
Unfortunately, it is not possible to use 'or' in a clause.
Best regards,
PC

Ido Carmi

unread,
Nov 3, 2016, 3:00:23 AM11/3/16
to pyDatalog
Ah ok, thanks!
Reply all
Reply to author
Forward
0 new messages