Dear Abdel Ali Ed Dbali,
thank you for the answer, it helped me a lot.
Abdel Ali Ed Dbali wrote:
>
> Quoting randomizer <[EMAIL PROTECTED]>:
>
>>
>> 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
> [email protected]
> 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.
_______________________________________________
Users-prolog mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/users-prolog