Prolog Operator Expected Error
Contents |
here for a quick overview of the site Help Center
Syntax Error: , Or ) Expected Prolog
Detailed answers to any questions you might have Meta Discuss prolog syntax error the workings and policies of this site About Us Learn more about Stack Overflow the prolog syntax error . or operator expected after expression company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss
Warning Singleton Variables Prolog
Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Syntax Error: Operator expected in SWI Prolog up vote 1 down vote favorite I keep getting a syntax error
Syntax Error Operator Expected Ocaml
every time I try to compile this buffer. I've gone through the ordinary steps of removing all spaces, but still I keep getting the same error every time. solve_puzzle(Swimmers):- Swimmers=[_Girl1,_Girl2,_Girl3], [girl(_,_,_,first),girl(_,_,_,second),girl(_,_,_,third)]=Swimmers, is_faster(girl(claudia,_,_,_),(_,_,cheltenham_girls,_),Swimmers), is_faster(girl(mary,_,_,_),girl(_,table_tennis,_,_),Swimmers), member(girl(_,weightlifting,_,first),Swimmers), member(girl(mary,_,sydney_girls_high_school,_),Swimmers), member(girl(claudia,ballroom_dancing,_,_),Swimmers), member(girl(_,_,hornsby_girls_high_school,_),Swimmers). is_faster(F,S,[F|[S|_]]). is_faster(F,S,[F,S,[_|Rest]]):- is_faster[F,S,Rest). Whats doing this? I seem to run into this every time I attempt prolog. prolog syntax-error share|improve this question edited Sep 15 '15 at 12:34 repeat 12.9k427121 asked Sep 15 '15 at 7:49 David 82 3 SWI even tells you the exact line of the error. Write: is_faster(F, S, [F,S,_|Rest]) :- is_faster(F, S, Rest). to at least fix the syntax error (semantic problems may still be present). Removing all spaces is certainly not required or recommended. Also, check out more convenient list syntax: You can write the penultimate clause equivalently as is_faster(F, S, [F,S,_]). (again, just considering syntax, and leaving the semantics unchange
here for a quick overview of the site Help Center arguments are not sufficiently instantiated Detailed answers to any questions you might have Meta Discuss
Prolog Not Operator
the workings and policies of this site About Us Learn more about Stack Overflow prolog predicate the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x http://stackoverflow.com/questions/32580525/syntax-error-operator-expected-in-swi-prolog Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How can I fix Prolog Syntax error: Operator expected error? up vote 0 down vote favorite PROLOG: “Syntax http://stackoverflow.com/questions/22213688/how-can-i-fix-prolog-syntax-error-operator-expected-error error: Operator expected” ERROR: c:/users/zulfekarali/Desktop/KBS/kbs.pl:2:3: Syntax error: Operator expected % c:/Users/ZulfekarAli/Desktop/KBS/kbs.pl compiled 0.00 sec, 27 clauses -------- domains disease,indication = symbol Patient,name = string predicates hypothesis(string,disease) symptom(name,indication) response(char) go clauses go :- write("What is the patient's name? "), readln(Patient), hypothesis(Patient,Disease), write(Patient,"probably has ",Disease,"."),nl. go :- write("Sorry, I don't seem to be able to"),nl, write("diagnose the disease."),nl. symptom(Patient,fever) :- write("Does ",Patient," have a fever (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,rash) :- write("Does ",Patient," have a rash (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,headache) :- write("Does ",Patient," have a headache (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,runny_nose) :- write("Does ",Patient," have a runny_nose (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,conjunctivitis) :- write("Does ",Patient," have a conjunctivitis (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,cough) :- write("Does ",Patient," have a cough (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,body_ache) :- write("Does ",Patient," have a body_ache (y/n) ?"), response(Reply), Reply='y'. symptom(Patient,chills) :- write("Does ",Patient," have a chills (y/n) ?"), respon
Session Lecture 4 Slides Practical Session Lecture 5 Slides Practical Session http://cs.union.edu/~striegnk/courses/esslli04prolog/practical.day1.php?s=practical.day1.node4 Interpreting the error messages and warnings that http://swi-prolog.996271.n3.nabble.com/Newbie-common-Syntax-error-Operator-expected-td7382.html Prolog may give you Prolog will tell you if the things that you are writing are syntactically incorrect. Download the knowledge base kb.syntax_error.pl and load it into Prolog. You will get the following answer. ?- consult('kb.syntax_error.pl'). syntax error ERROR: /home/kris/lehre/esslli04/esslli04prolog/kbs/kb.syntax_error.pl:5: Syntax error: Operator expected ERROR: /home/kris/lehre/esslli04/esslli04prolog/kbs/kb.syntax_error.pl:11: Syntax error: Operator expected ERROR: /home/kris/lehre/esslli04/esslli04prolog/kbs/kb.syntax_error.pl:14: Syntax error: Unexpected end of clause ERROR: /home/kris/lehre/esslli04/esslli04prolog/kbs/kb.syntax_error.pl:17: Syntax error: Unexpected end of file % kb.syntax_error.pl compiled 0.00 sec, 1,348 bytes Yes This tells you that there are four syntax errors. prolog syntax error It also tells you that the Prolog interpreter thinks that the errors are in lines 6, 12, 15, and 18. And it gives you some indications as to what might cause the problems (operator expected, unexpected end of clause/file). Which are the mistakes? Solutions Another thing that you might get complaints about are singleton variables; i.e., variables which are used only once in a clause. Download the knowledge base kb.singleton_vars.pl and load it into Prolog. You will get the following: ?- consult('kb.singleton_vars.pl'). Warning: (/home/kris/lehre/esslli04/esslli04prolog/kbs/kb.singleton_vars.pl:8): Singleton variables: [X, Y] % kb.singleton_vars.pl compiled 0.00 sec, 1,520 bytes Yes Prolog tells you that X and Y are singleton variables in the clause starting at line 8. Prolog warns you when it detects singleton variables, because singleton variables are often due to a typo (as in our exa
♦ ♦ | Report Content as Inappropriate ♦ ♦ Newbie: common Syntax error: Operator expected I have such code which is copy-pasted from book: PREDICATES f(integer, integer) CLAUSES f(X, 0) :- X<3, !. f(X, 2) :- X>=3, X<6, !. f(X, 4) :- X>=6. When I try to run it in SWI-Prolog I get error: 1 ?- consult(q). ERROR: c:/users/admin/documents/q.pl:2:4: Syntax error: Operator expected % q compiled 0.00 sec, 1,136 bytes true. What should I fix to run under SWI-Prolog? Uwe Lesta Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: Newbie: common Syntax error: Operator expected Vladimir Mihailenko schrieb: > I have such code which is copy-pasted from book: > > PREDICATES > f(integer, integer) > CLAUSES > f(X, 0) :- X<3, !. > f(X, 2) :- X>=3, X<6, !. > f(X, 4) :- X>=6. > > When I try to run it in SWI-Prolog I get error: > > 1 ?- consult(q). > ERROR: c:/users/admin/documents/q.pl:2:4: Syntax error: Operator expected > % q compiled 0.00 sec, 1,136 bytes > true. > > What should I fix to run under SWI-Prolog? The code above is TURBO-PROLOG. cut off the first three lines and try again -- Kind regards Uwe Lesta _______________________________________________ SWI-Prolog mailing list [hidden email] https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog Paulo Moura Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: Newbie: common Syntax error: Operator expected In reply to this post by Vladimir Mihailenko On 2009/10/28, at 14:38, Vladimir Mihailenko wrote: > I have such code which is copy-pasted from book: > > PREDICATES > f(integer, integer) > CLAUSES > f(X, 0) :- X<3, !. > f(X, 2) :- X>=3, X<6, !. > f(X, 4) :- X>=6. > > When I try to run it in SWI-Prolog I get error: > > 1 ?- consult(q). > ERROR: c:/users/admin/documents/q.pl:2:4: Syntax error: Operator > expected > % q compiled 0.00 sec, 1,136 bytes > true. > > What should I fix to run under SWI-Prolog? > -- The code seems to be written for VisualProlog, which, despite its name and being a fine language, is not Prolog as me and others understand it. To compile the code above remove the lines in all-caps. Cheers, Paulo ----------------------------------------------------------------- Paulo Jorge Lopes de Moura, PhD Assistant Professor Dep. of Computer Science, University of Beira Interior 6201-001 Covilhã, Portugal Office 3.18 Ext. 3276 Phone: +351 275319891 Fax: +351 275319899 Email: