Re: Users-prolog Digest, Vol 71, Issue 5

Duncan Patton a Campbell <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Organization NeoText
Message-ID <[email protected]>

> > GNU Prolog 1.3.1
> > By Daniel Diaz
> > Copyright (C) 1999-2009 Daniel Diaz
> > | ?- even(X).
> > uncaught exception: error(existence_error(procedure,even/1),top_level/0)
> 
> I'm a bit rusty, and only just installed gprolog myself, and am not
> familiar with its messages.  But it looks to me like there is no
> predicate 'even/1' defined -- "existence_error(procedure,even/1).

"existence_error" means there is no such predicate available to
the interpreter: it is neither a built-in nor user construct.

Amongst other places, the Gprolog docs are at

http://www.gprolog.org/manual/html_node/index.html

and you can find the builtin predicates in 

http://www.gprolog.org/manual/html_node/gprolog-idx.html

To create a user defined predicate, even/1, you would 
open a text file, called test2.pl with notepad (or some
other text editor) and enter the line:

even(X):- U is X mod 2, !,U == 0.

save the file and at the interpreter prompt enter

| ?- [test2]. 

and then

| ?- even(12).


So now U have defined a user predicate called even
that tests for "evenness" with the mod function.


Dhu

> 
> Try something like reverse([1,2,3],X).  If that doesn't work, you have
> an installation error.
> 
> >
> > not sure if the installation was wrong, but got not errors or I'm missing
> > something very simple.
> > also is there a good FAQ's page for this interpreter.
> 
> Google "gprolog tutorial"  I get lots of hits.  I think you need a tutorial
> rather than a FAQ.  Work through some of these.
> 
> >
> > many thanks
> >
> > James.
> >
> > ps. sorry if this is a silly posting but didn't know what else to try :S 
> 
> Good luck.   This looks like a low traffic list, so I thought I'd go ahead and answer
> instead of waiting for a expert.
> 
> John Velman
> 
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> Users-prolog mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/users-prolog
> 
> 
> End of Users-prolog Digest, Vol 71, Issue 5
> *******************************************
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.