News for hackers. Stuff that matters.
Re:Ask HN: Why isn't Prolog more popular? by tom_mellior on Monday May 29, 2017 @04:08PM (#14441131)
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 .

There are no comments on this comment yet.