users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: differences in implementation


From: randomizer
Subject: Re: differences in implementation
Date: Thu, 30 Aug 2007 08:11:04 -0700 (PDT)

Dear Abdel Ali Ed Dbali,
thank you for the answer, it helped me a lot.

Abdel Ali Ed Dbali wrote:
> 
> Quoting randomizer <address@hidden>:
> 
>>
>> I am using a simple kb from a book "Learn prolog now!",
>> wizard(ron).
>> hasWand(harry).
>> quidditchPlayer(harry).
>> wizard(X) :- hasBroom(X),hasWand(X).
>> hasBroom(X) :- quidditchPlayer(X).
>>
>> gnu prolog answers question wizard(harry).  "no", and swi prolog answers
>> "yes".
>> anyone has an idea why does it happen?
>> --
> 
> Hi,
> 
> GnuProlog is very close to ISO prolog in most of its concepts. In ISO
> prolog, the clauses of a predicate P/N must be contiguous!
> In you example, wizard/1 is not. That's why the second clause was ignored.
> 
> | ?- consult('user').
> compiling user for byte code...
> wizard(ron).
> hasWand(harry).
> quidditchPlayer(harry).
> wizard(X) :- hasBroom(X),hasWand(X).
> user:4: warning: discontiguous predicate wizard/1 - clause ignored
> hasBroom(X) :- quidditchPlayer(X).
> 
> user compiled, 6 lines read - 595 bytes written, 13840 ms
> 
> yes
> 
> ... See the WARNING above.
> 
> The listing predicate gives the first clause only.
> 
> | ?- listing(wizard).
> wizard(ron).
> 
> yes
> 
> So, you have to use the directive "contiguous" before the first clause of
> your predicate :
> 
> | ?- consult('user').
> compiling user for byte code...
> :- discontiguous(wizard/1).
> wizard(ron).
> hasWand(harry).
> quidditchPlayer(harry).
> wizard(X) :- hasBroom(X),hasWand(X).
> hasBroom(X) :- quidditchPlayer(X).
> user compiled, 7 lines read - 801 bytes written, 34422 ms
> 
> yes
> | ?- listing(wizard).
> 
> wizard(ron).
> wizard(A) :-
>          hasBroom(A),
>          hasWand(A).
> yes
> | ?- wizard(harry).
> 
> yes
> 
> Good luck.
> 
> Ali.
> 
> 
> 
> 
> _______________________________________________
> Users-prolog mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/users-prolog
> 
> 

-- 
View this message in context: 
http://www.nabble.com/differences-in-implementation-tf4349295.html#a12409280
Sent from the Gnu - Prolog - Users mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]