Reputation: 10777
I am new to prolog and trying a very simple example on http://www.compileonline.com/execute_prolog_online.php . Here is my code:
:- initialization(main).
main :-
female(ayse).
?- female(ayse).
But it gives an error saying that:
/web/com/136989421322328/main.pr:5:4: syntax error: . or operator expected after expression
1 error(s)
compilation failed
where line 5 is the line starts with ?. What is wrong here? Can anyone help?
Thanks.
Upvotes: 0
Views: 380
Reputation: 14873
This code works:
:- initialization(hello).
hello :- write('hello').
Lines:
you say you want to have a predicate called hello that will be specified in the following lines that shell be executed when everything is loaded.
you declare the predicate.
"hello implies write('hello') is true"
What you wanted to write is
:- initialization(main).
female(ayse).
main :- female(ayse), write('ayse is female').
Upvotes: 2