Recent submissions

Comment · 9 years ago
Thank you for all you great tips. Do you know any good book(except Craft of Prolog, Prolog for AI) or good code on github following this principle?
Comment · 9 years ago
Wow, modelling it like in a relational DB is a great idea! Thanks. Your trick of adding names of the properties like "_id_user_text" is neat. In the past, I tried a similar solution like but I would always forget which property is at which position.

How would you make sure that the rights of admins are only delete, hide, and modify (and not e.g. walk, talk, chalk) ? If I use

  admin_id_rights(Id, Rights):- numeric(ID), sort(Right, SortedRights), subset(SortedRights, [delete, hide, modify]). ,
then I obviously have added all possible admins.

Moreover, how would you then 'create' objects without adding them with asserta. Assume that all the user, admins, comments are written to a text file which should be queried. I can easily read them into some nested compounds with DCGs. However, I would like to create objects(e.g.like Java's new) to check that they adhere to the contraints of my model.

Comment · 9 years ago
I tried programming in prolog and read some introductionairy books. However, no book talks about how you would define more complex 'types' objects. How would you model the following domain in prolog:

Comment: Attributes: text, points

User: Attributes: name, emailAdress(as a struct of first part, domain, top-level-domain)

Admin(a special user): additional Attributes: set of rights(can delete, can hide, can modify)

Finally, there is an n-1 assocation between Comment and User and I want to make some queries about this domain.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton