Re: Trying to setup a hierarchy of classes of things (SWI prolog)



This is starting to smell like a homework assignment. If so, we
shouldn't be doing it for you, but we can always give vague tips and
general advice.

I haven't scrutinized your code in detail, but I'm not sure why you
can't easily enough get around having to manually code up what someone
has. It would seem that if you call current_has() and that person
doesn't have that particular object, the predicate should simply fail
and return "No." Does this natural behavior suit your needs? If not,
call a custom initialization predicate which will initialize things to
zero if current_has() fails. So if current_has(John, tomato, X)
fails, init(John, tomato, 0). I am assuming this would be called from
somewhere in your current_has() predicate, but I could be wrong, so
think about it. Also, you may have to use an if-then type of
structure (I don't know).

Let us know how the project is coming.

.



Relevant Pages

  • Re: how to redefine call/2 ?
    ... > except that if the predicate is not defined it fails instead of throwing. ... > if call(P, Arg) succeeds, holds must succeed. ... > am using call/2 and declaring each predicate dynamic, so calldoes ...
    (comp.lang.prolog)
  • how to redefine call/2 ?
    ... I would like to define a holds/2 predicate that behaves like call/2, ... except that if the predicate is not defined it fails instead of throwing. ... if call(P, Arg) succeeds, holds must succeed. ...
    (comp.lang.prolog)
  • Re: Prolog - Displaying Error Messages
    ... error message to the user if something fails inside a predicate, ... In the xupdate/2 predicate, if PName contains a bad value then Call ... obviously fails and returns No. ...
    (comp.lang.prolog)
  • Prolog - Displaying Error Messages
    ... error message to the user if something fails inside a predicate, ... In the xupdate/2 predicate, if PName contains a bad value then Call ... obviously fails and returns No. ...
    (comp.lang.prolog)
  • Re: One cent question
    ... > Now, I'm asking Prolog: ... > predicate, and not a list! ... X = cheese ... X = tomato ...
    (comp.lang.prolog)