Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to represent "Alberich hates everyone but himself" in Prolog?

Tags:

prolog

I'm currently learning prolog and I'm trying to get the syntax right for "Alberich hates everyone but himself". I suppose I could represent "Alberich hates everyone" as hates(Alberich, X) but how do I represent "but himself" ?

like image 946
Haise Sasaki Avatar asked Feb 01 '26 10:02

Haise Sasaki


1 Answers

You specify that X is different from albrich:

hates(alberich, X) :-
    dif(alberich, X).

Note that constants start with a lowercase, so you should use alberich, not Alberich, since Alberich is just a variable that has as identifier Alberich.

like image 192
Willem Van Onsem Avatar answered Feb 04 '26 00:02

Willem Van Onsem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!