“Syntax error: Operator expected” in Prolog
Remove the space between edge and the opening parenthesis. Spaces delimit terms, so Prolog will think that edge is an operator rather than the functor of a compound term.
Remove the space between edge and the opening parenthesis. Spaces delimit terms, so Prolog will think that edge is an operator rather than the functor of a compound term.
A standard prolog predicate will do this. will evaluate to true if you call it with 5 and fail(return false) if you run it with anything else. For not equal you use \= Technically it is does not unify, but it is similar to not equal. Learn Prolog Now is a good website for learning … Read more
I am writing this answer, because the best answer yet was in a comment by lurker. I want to have it show up as an actual answer. Your code is not working, because you’re doing R1 is R+1 when R isn’t instantiated in the case not_number([X|T], R). Your recursive case is strung a little backwards. … Read more
Singleton variables are useless in Prolog, and are easily introduced by editing typos. The warning is welcome to me, as it allows to easily spot such frequent cause of error. Being a warning, you can run code containing singletons, but any value these eventually will assume will be lost. I don’t think that ISO standard (never heard about ANSI) forbids such variables. You could … Read more
I don’t know what do you mean by “not equal” (does not unify?), but you could try these:
It’s the ‘not provable‘ operator. It succeeds if its argument is not provable (and fails if its argument is provable).