3 ms·
Here's a shot. As you don't declare relations in Prolog the way you would, say, write SQL CREATE statements, I'll just show the data model on concrete data.
by tom_mellior 9y ago
Here's a shot. As you don't declare relations in Prolog the way you would, say, write SQL CREATE statements, I'll just show the data model on concrete data.
comment("I tried programming in prolog...", 100, randomUser1122).
comment("Here's a shot.", 2, tom_mellior).
user(randomUser1122, email(random, randomdomain, com)).
user(tom_mellior, email(tom, mellior, su)).
admin_right(randomUser1122, delete).
admin_right(randomUser1122, modify).
Is there a user from the Soviet Union with admin rights?
?- user(User, email(_, _, su)), admin_right(User, right).
false.
What rights do users with posts with a score of at least 10 have?
?- comment(_, Score, User), Score >= 10, admin_right(User, Right).
Score = 100,
User = randomUser1122,
Right = delete ;
Score = 100,
User = randomUser1122,
Right = modify .