简体   繁体   中英

Combining two facts via a boolean OR in Gnu Prolog

I'm totally new to Prolog. So please excuse this possibly extermely simple qiuestion: I have a few facts like

likes(peter,cars).
likes(maria,bikes).
likes(walter,bikes).
likes(paul,bikes).
likes(paul,cars).

in a file likes.pl . Now I'm trying to check whether paul likes cars and bikes , so I tried on GNU Prolog's REPL:

| ? - [likes].
| ? - likes(paul,bikes) #\/ likes(paul,cars).

but I get "uncaught exception:...". Obviously I'm doing something wrong. - How can I combine two facts with an AND in GNU Prolog?

The operator you are using #\/ is a Boolean Finite Domain operator used in constraint programming clp(b) .

If you just want a conjunction of two facts A and B, use A, B . If you want a disjunction of them use A; B A; B .

In your case you can just type likes(paul, bikes), likes(paul, cars). .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM