Prolog syntax error: operator expected - prolog

I was studying the Prolog, and met with the "syntax error: operator expected" for the following code:
odd_list(X,Y):-process_list(X,Y,1).
process_list(X,[N1|Y],N):-N1 is 2*N-1,N1 < X,N2 is N+1,process_list(X,Y,N2).
process_list(X,[],N):-2*N-1>=X.
That's all the code I wrote. What's the problem? I found some solutions saying that there are unexpected white spaces in the functors or arguments, but I think I do not include any white space in the above-mentioned places.
Thank you all for helping me!!!
Remark: I find that when I name the source code as "Test1.pl", I get this error. But when I name it as "test1.pl", there is no error. Does it mean that the file name cannot start with an upper case letter?

I found the reason for this problem. I used the file name 'Test1'. But Prolog does not support upper case letter in the file name. I modified the file name to 'test1' and it works now.

Related

Replacing a string gives "A definition for the symbol "..." could not be located" error VS2019

I want to change a section of code that has thousands of lines. The section I want to change exists on many lines and I don't want to do it one by one. When I right click on FormQQ_ATL and say replace, it gives "A definition for the symbol FormQQ_ATL could not be located error VS2019".image:
I guess I can't do that because it is a string. Is there way to solve this situation?

What means SPSS syntax Error n° 10933 and how to resolve it?

I am currently running an aggregate function and I get :
Error n° 10933 in column 1. Text: DATASET
The definition of a new variable on the AGGREGATE command must be
terminated by a slash.
This command not executed.
I want to have the fertility ratio (Child-Woman ratio) from a 1911 census. Here is my syntax (I added the spaces here):
Screen shot of the syntax here
I just don't understand why it cannot go through and adding slashes does not help either.
I seems to be a very banal error.
Does anyone have any advice ?
Thank you !
SPSS commands should be ended with periods. Your syntax treats the DATASET ACTIVATE as a continuation of the AGGREGATE command, and the parser thinks "DATASET" is a new variable. Put a period after the closed parentheses to finish the command.

prolog read from file throws error on special characters

I am working in Prolog, and am trying to read in from a file. The first line is a password. With the password, I want to be able to use special characters.
Here is the read file code:
readfile(Filename):-
open(Filename, read, Str),
read(Str, Thepassword),
read(Str, Thefirewall),
close(Str),
nb_setval(password, Thepassword),
nb_setval(firewall, Thefirewall).
This works fine until I change the password from brittany to britta!y, then I get ERROR: computer1.txt:1: Syntax error: Operator expected.
Anyone know what I should do?
read/2 reads Prolog terms. What you probably want is to read the whole line regardless it is in Prolog syntax or not.
In SWI Prolog you can use the predicate read_line_to_codes/2 instead. (See the SWI manual entry). You must include the library with use_module(library(readutil)) first.
SICStus has a similar predicate called read_line/1/2.
If you need an atom instead of a list of codes, you can convert it with atom_codes/2.

MicroStrategy ApplySimple Syntax

i'm trying to use the ApplySimple function in order to define a Metric in MicroStratey. My gloal is to cast a fact column to double value.
My current metric definition is:
ApplySimple("TO_DOUBLE(#0)", MYFACT)
The syntax check reports a wrong expression and indicates the error by marking the comma.
I tried to remove the MYFACT parameter including comma, but the syntax check fails as well, indicating the error on right parenthesis.
ApplySimple("TO_DOUBLE(MYFACT)")
Any suggentions on how to correct the syntax?
Thank you very much!
Kind regards
Okay, just got the problem. You have to use ";" insted of "," after the expression.

Ruby Regex error

My regex:
https?://[\w-]+(?:\.[\w-]+)+(?:/[\w-]+)*(?:[./%?=&#-]\w+)+)?
In Ruby, I get the following error:
unmatched close parenthesis:/https?://[\w-]+(?:\.[\w-]+)+(?:/[\w-]+)*(?:[./%?=&#-]\w+)+)?/'
How can I fix this?
I don't know how I could be clearer than the error message. Your regex has an unmatched close parenthesis.
https?://[\w-]+(?:.[\w-]+)+(?:/[\w-]+)*(?:[./%?=&#-]\w+)+)?
Notice how there's 3 ( and 4 )
Further reading in regexes http://www.regular-expressions.info/tutorial.html
Specifically, you may want to check out the character information http://www.regular-expressions.info/characters.html
There seems to be one "close parenthesis" too much.
as it also says in the error message ;)

Resources