Nevvea
Nevvea

Reputation: 67

Prolog script not loaded properly

I'm trying to load my hw4.pl into swipl and it doesn't seem to be working. I tried

swipl -s hw4.pl

and in the prolog shell,

[hw4]. 
['hw4'].
consult('hw4.pl').

It would say "true", but I don't see the "complied" line.

And when I try to query:

?- user(@anna).
ERROR: toplevel: Undefined procedure: user/1 (DWIM could not correct goal)

My hw4.pl:

assert(user(@anna)).
assert(user(@tom)).
assert(user(@jeremy)).
assert(user(@lawrence)).

Any idea why? Thanks in advance!

Upvotes: 1

Views: 60

Answers (1)

Matt
Matt

Reputation: 4049

Here's what I get when I try to load your file:

ERROR: hw4.pl:1:13: Syntax error: Operator expected
ERROR: hw4.pl:2:13: Syntax error: Operator expected
ERROR: hw4.pl:3:13: Syntax error: Operator expected
ERROR: hw4.pl:4:13: Syntax error: Operator expected

I'm pretty sure that @ is not valid syntax. Change your file to

assert(user(anna)).
assert(user(tom)).
assert(user(jeremy)).
assert(user(lawrence)).

And you should be fine.

Upvotes: 1

Related Questions