So to Write A prolog programming .
First Fire up your SWI -PROLOG software.
then you will see something like this .
Welcome to SWI-Prolog (threaded, 64 bits, version 7.4.2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- _
1. So now go to File>NEW....
and give any name to knowledge base file. I Give it factorial
.pl
now write the follwing fact and rules .
fact(0,1) .
fact(N,R):-
N>0, N1 is N-1,
fact(N1,R1),
R is N*R1.
now press ctrl +s to save .
3. now close this windows .
4. now in the main window goto file > Consult.....
and select your factorial.pl
5. now you can type query like fact(5,X).
it will return X=120.
done.....
here are some screen shot :
Comments
Post a Comment
share your thoughts ....