Re: Newbie, *really* basic question

From: Scott Bourbon (SCottB_at_hotmail.com)
Date: 07/05/04


Date: Mon, 05 Jul 2004 07:11:03 +0200

Hi there,

I haven't tried with Ciao yet: after years of absence I'm back to
Prolog, finding a lot of interesting novelties.

Now: I suppose this is implementation dependent, but at least with
gprolog 1.2.16 you can get what you expected with

set_prolog_flag(unknown,fail).

| ?- likes(mary,john).
likes(mary,john).
uncaught exception: error(existence_error(procedure,likes/2),top_level/0)
| ?- set_prolog_flag(unknown,fail).
set_prolog_flag(unknown,fail).

yes
| ?- likes(mary,john).
likes(mary,john).

no
| ?-

It is to say you can get some control over the kind of Prolog reaction
to a query containing an unknown predicate.

Actually, the set_prolog_flag can act on various other aspects of the
interpreter, in gprolog;

Cheers,

        Andrea Fedeli.

PS: I've just checked with SWI-Prolog: set_prolog_flag(unknown,fail). is
accepted, but it does not produce the same effect that in gnu prolog.

--
Bryan Glennon wrote:
> So, with time on my hands I decided to learn Prolog. Downloaded Caio 
> Prolog, and got a copy of Programming in Prolog by Clocksin & Mellish. I 
> am stuck on the first example. Here's the session output:
> 
> Ciao-Prolog 1.9 #342: Sat Apr 24 20:46:05 2004
> ?- likes(john, mary).
> {ERROR: user:likes/2 - undefined predicate}
> 
> no
> ?-
> 
> I realize it's telling me that there is no predicate "likes" that takes 
> 2 arguments, but nothing I have read indicated that I need to define 
> that predicate somewhere.
> 
> What am I missing?
> 
> Thanks,
> Bryan


Relevant Pages

  • Re: Sublists question
    ... I do not really get what the predicate means or does. ... >>helps just to write the predicate out clearly in natural language, ... >>then translate into Prolog. ... more as a functional programming language than as a logic ...
    (comp.lang.prolog)
  • Re: Prolog module system
    ... I think prolog offers so much freedom that one can build its own ... Both modules define a member/2 predicate, ... this leads to a name conflict. ... shaky ground as current module systems (look at the issues with e.g. ...
    (comp.lang.prolog)
  • Re: Prolog, memory management and memory leaks
    ... predicate is executed that solves constraint problem. ... In some circumstances, this server leaks memory. ... "Understanding Memory Management in Prolog ... There is not just one garbage collector in Prolog. ...
    (comp.lang.prolog)
  • Re: Prolog module system
    ... my experiment with oop and modules has almost reach a point ... On the other hand, when I came to Prolog as a logic programming language, I ... Consider the length/2 predicate. ... OO systems have much more complex built-in lookup rules. ...
    (comp.lang.prolog)
  • Re: Prolog module system
    ... We talked a bit about this on the Prolog standardization forums but is ... Both modules define a member/2 predicate, ... this leads to a name conflict. ... shaky ground as current module systems (look at the issues with e.g. ...
    (comp.lang.prolog)