Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

first steps

270 views
Skip to first unread message

Haris Bogdanovich

unread,
Sep 23, 2011, 7:18:45 AM9/23/11
to
Hi.

When I entuer in gnu prolog:
man (adam).
I get the following error:
uncaught exception: error(syntax_error('user_input:1 (char:5) . or operator
expected after expression'),read_term/3)
That would be entering a fact.
What am I doing wrong ?

Thanks

Andrew Davison

unread,
Sep 23, 2011, 8:44:29 AM9/23/11
to
You are putting a space between 'man' and the '('.

Haris Bogdanovich

unread,
Sep 23, 2011, 8:57:43 AM9/23/11
to
> You are putting a space between 'man' and the '('.

Now I wrote:
man(adam).
without a space and I got:
uncaught exception: error(existence_error(procedure,man/1),top_level/0)
What's wrong now ?


Tomasz Budzeń

unread,
Sep 23, 2011, 9:38:22 AM9/23/11
to

You try to query fact man/0, but you didn't have any facts in
database, so you get existence_error.
So you can either declare fact: ?- assertz(man(adam)).
or consult Prolog source file containing your facts, man(adam). or
man(X).

Regards,
Tomasz Budzeń

Chip Eastham

unread,
Sep 23, 2011, 12:14:09 PM9/23/11
to
> Tomasz Budzeñ

This is something of a quirk/feature of gprolog.
Many implementations will return "no" or "false"
in such a case.

[GNU Prolog: Existence error]
http://www.gprolog.org/manual/gprolog.html#htoc40

Existence errors can be "caught" and handled by a
user supplied predicate.

This behavior can be changed by setting of a Prolog
flag called "unknown". See here for the possible
values of that changeable flag:

http://www.gprolog.org/manual/gprolog.html#set-prolog-flag/2

regards, chip

Chip Eastham

unread,
Sep 26, 2011, 11:34:01 AM9/26/11
to
It occurs to me perhaps you really mean to "assert" the fact
man(adam),
rather than to query to see if it is true. To do this assertion:

:- assert(man(adam)).
yes

After that any queries for "man(adam)" will succeed.

regards, chip

0 new messages