For Programmers: Free Programming Magazines  


Home > Archive > Prolog > January 2006 > Where can I find the GNU Prolog grammar syntax?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Where can I find the GNU Prolog grammar syntax?
iikonos

2005-12-16, 3:57 am

Hi,

I hope this will not bother you.
I have some prolog code written in Turbo Prolog and I want to rewrite
them in GNU prolog but I find it's different in the grammar between two
system.
Is anyone so kind to tell me where can I find the GNU grammar syntax?
Thanks you all.


iikonos

Duncan Patton

2005-12-16, 3:57 am

On 15 Dec 2005 20:49:18 -0800
"iikonos" <iikonos@gmail.com> wrote:

> Hi,
>=20
> I hope this will not bother you.
> I have some prolog code written in Turbo Prolog and I want to rewrite
> them in GNU prolog but I find it's different in the grammar between two
> system.
> Is anyone so kind to tell me where can I find the GNU grammar syntax?
> Thanks you all.
>=20


GNU Prolog is "Clocksin & Mellish" with a bunch of consistent enhancements,
so that's the book you should look at.

Somewhere in the Turbo Prolog docs there are discussions about the differen=
ces,
and this:

http://en.wikipedia.org/wiki/Prolog

also, would be a good place to read.

Dhu


>=20
> iikonos
>=20



--=20
???????????????????????????????????????

Open Systems Integration

Contact Fubar the Hack: fubar AT neotext.ca

Area code seven eight zero, Exchange four six six, Local zero one zero nine

Highland terms, Canadian workmanship.

All persons named herein are purely fictional victims
of the Canidian Bagle Breeder's Association.

Save the Bagle!=20

Sun =D0hu


???????????????????????????????????????

iikonos

2005-12-17, 3:58 am

I was and can u give me a hint on this simple case?
This is a standard program written in Turbo Prolog and it words well.
But it cannot be recognized in gnuprolo when I use consult(...)

Domains
n,re=integer
Predicates
fab(n, re).
Clauses
fab(1,1).
fab(N, Res) :-
N>0,
N1=N-1,
fab(N1,R),
Res=R*N.


So, I remove all unnecessary part as follows but it still wors bad.
Can u show me 2 basic skills? 1) how to output/print an integer
varialbe's value using write()/print() etc ? 2) How to use integer
variable in gnuprolog?
Thank u.
I will check out the doc(s) you refered in your last reply.

########################################
#############
| ?- consult(fab).
compiling /home/wydeng/prolog/fab.pl for byte code...
/home/wydeng/prolog/fab.pl compiled, 6 lines read - 765 bytes written,
10 ms

yes
| ?- fab(10,N).

no
| ?- listing.

fab(1, 1).
fab(A, B) :-
A > 0,
C = A - 1,
fab(C, D),
B = D * A.

yes
| ?-

Bart Demoen

2005-12-17, 3:58 am

iikonos wrote:

> | ?- fab(10,N).
>
> no
> | ?- listing.
>
> fab(1, 1).
> fab(A, B) :-
> A > 0,
> C = A - 1,
> fab(C, D),
> B = D * A.
>
> yes


In Prolog, = mens unification, not arithmetic evaluation.
Use is instead:

fab(1, 1).
fab(A, B) :-
A > 0,
C is A - 1,
fab(C, D),
B is D * A.

?- fab(10,N).

N = 3628800

(why fab and not fac ?)

Cheers

Bart Demoen
iikonos

2006-01-10, 4:10 am

Thank you Bart Demoen :)
Thank you very much.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com