Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax errors help 1

Status
Not open for further replies.

200878456

Technical User
Mar 7, 2009
6
getting this error:

| ?- Computer(X) :- Mac(X).
! Syntax error
! operator expected after expression
! in line 20
! Computer
! <<here>>
! ( X ) :- Mac ( X ) .
| ?-

any ideas what's wrong?
 
In SWI-Prolog, you can't write "Computer(X) :- Mac(X)." at top level.
It must be written in a file of rules.
Also, don't forget that a fonctor begins with a lowercase caracter e.g. "computer(X) :- mac(X)."
Uppercase letters begin variables.
 
So I have to write this in notepad, and then import it?

thanks
 
Yes, if you use Linux, with Microsoft, you have an integrated editor.
 
thanks, just one more question

I have:

memory(laptop, 512mb).

and it gives me syntax error.... looks like it doesn't like the numbers, is there any way to have "512mb" or do I have to write it as a word?
 
what's wrong here?

os(jacobsdesktop, windows).

I'm getting an error:

* clauses for user:eek:s/2 are not together

I also tried:

os(X, windows) :- jacobsdesktop(X).

but getting the same error :S

any ideas?
 
* clauses for user:eek:s/2 are not together"
In your file, you must write your clauses one following the others.
you must not have
Code:
 rule1 :-
..........
..........

rule2 :-
...........
...........

rule1 :-
.............
.............
 
so how should I write it? The problem is because I have "os" for a laptop and for a desktop

so

os(jacobsdesktop, windows).

and

os(jacobslaptop, mac).

how would I write it?
 
I don't understand where is your problem.
You write the two facts in the database
Code:
os(jacobsdesktop, windows).
os(jacobslaptop, mac).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top