Better HN
topnewbestaskshowjobs
Log inSign up

randomUser1122

4 karma · joined May 29, 2017 (9y ago) · 3 submissions

Submissions

comment 9y ago · link · parent

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 9y ago · link · parent

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 9y ago · link · parent

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.