I'm going through a learn Prolog tutorial. I pulled a single line from the example:
happy(yolanda).
and put it into an XGP file. When I compile it I get:
syntax error: expression expected
This same line works ok when I load it into swipl so I guess there's some difference there.
How can I run happy(yolanda) and get a Yes that she is happy in XGP?
I think there was a bad character that showed up when I copy-pasted the code from the website into the .pl file. I deleted all the whitespace and the file started to compile.
happy(yolanda).
Once the file is saved then in the Evaluate Query box you can run happy(yolanda). and it will say 'Success' just as #lurker said.
Related
I'm trying to install libssh-0.8.5 onto Ubuntu 16.04 using the instructions from the install.readme provided. I follow every step as stated, but I get an error after executing the make command to build the project. The error is as follows:
[ 65%] Built target exec
tests/CMakeFiles/ssh_ping.dir/flags.make:8: *** target pattern contains no '%'. Stop.
CMakeFiles/Makefile2:1696: recipe for target 'tests/CMakeFiles/ssh_ping.dir/all' failed
make[1 ]: *** [tests/CMakeFiles/ssh_ping.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
I have researched and seen that it could be a syntax error somewhere in my make file that is preventing the build to continue. I have looked at the target make file giving the problem, but cant seem to identify what is causing the error.
The flag.make file is as follows:
The problem seems to be coming from the highlighted bold line. Can anyone see what I am missing?
On StackOverflow (and most other similar sites), please cut and paste text into your questions and format them using the proper markdown facilities, rather than attaching images containing text. The latter is difficult to read and we can't cut and paste it into our answer to show where things are going wrong.
You cannot embed newlines in quoted strings, in makefiles. Make is completely line-oriented and does not parse quotes at all. So to make this:
FOO = "bar
biz"
is not considered one line assigning a value containing a newline to a variable FOO. Instead, it's considered two lines, the first of which is assigning the value "bar to variable FOO and the second of which is a syntax error since make can't parse the string baz" as a valid command.
Apparently ssh wasn't installed properly on your platform, while cmake relies on it. I am a bit surprised that cmake itself did not raise an error when generating flag.make but as I don't use cmake I do not know whether it is its normal behaviour or not.
Anyway, when cmake tried to detect your version of OpenSSH it did it by running ssh and got an error message instead of the version number it wanted. This error message got inserted in the generated flag.make Makefile. Because the second line of this error message (I could copy-paste it here if it was not in a picture in your question) has the:
a: b: c
form, make tried to interpret it as a static pattern rule but as it contains no % wildcard character, make raised a syntax error.
What happens if you try to run /usr/bin/ssh -V on the command line?
As the title suggest, my prolog code is throwing a syntax error. Im not sure what Im doing wrong. Im using Swi for my IDE and I tried playing with it to fix the problem, but to no avail.
heres my simple prolog code with error
?-
| male(bob)
| male(jeff)
|
| female(jane)
| female(erica)
|
| father(bob,jane)
| mother(erica, jane)
|
| ?-mother(erica,X).
ERROR: Syntax error: Operator expected
ERROR: male(bob)
ERROR: ** here **
ERROR:
male(jeff)
female(jane)
female(erica)
father(bob,jane)
mother(erica, jane)
?-mother(erica,X) .
There are two phases of Prolog development: Writing the program and interacting with it in the Prolog shell. These two phases are separate. You don't write your program in the shell, at least not directly.
Save your facts in a file called family.pl (with a dot . at the end of each fact!), then start the Prolog shell. In the shell, you can load the program using
?- consult(family).
or
?- consult('family.pl').
Note that in the first case you leave off the .pl extension, but in the second case, if you do use the extension, you should use single quotes (') around the file name.
Now you can run your query:
?- mother(erica, X).
X = jane.
There are some other ways to load files, such as putting the file name between square brackets [] instead of using consult, or (for many Prolog systems) simply adding the file name on the command line.
Statements in prolog end with a dot:
male(jeff).
female(jane).
female(erica).
father(bob,jane).
mother(erica, jane).
I'm writing a small Ruby script that does a statistical analysis on a list of names generated by another script of mine.
When I run it with this command:
ruby [first script] [args] | ruby -- [second script] _
it throws this error:
./name_gen_test.rb:15:in `gets': No such file or directory # rb_sysopen - _ (Errno:ENOENT)
from .name_gen_test.rb:15:in `gets'
from .name_gen_test.rb:15:in `<main>'
(Apologies for typos; Powershell wouldn't let me copy/paste)
This is line 15:
until (cur_line = gets).nil?
Then there's the body of a loop, the rest of the code, etc. However, if I put this line:
gets
as the very first line, I get the same error. In fact, if I totally empty the file and have nothing but a call to gets, I get the error that the file '_' cannot be found.
How can I make it understand that '_' is a command line argument and not a file to be... read from, I guess? Why doesn't gets work like I expect it to (i.e. reading from the standard input)?
I'm running it with Powershell, if that makes a difference.
Sorry if this is a duplicate; simply Googling the error message leads to a dozen different issues and a dozen different solutions, none of which apply, and I couldn't figure out how to put this problem into a Google query.
STDIN.gets will do what you want. By default, gets is (pretty much) equivalent to ARGF.gets. ARGF reads from standard input if there are no ARGS, and from files that correspond to ARGS if there are.
So here is a method in my program where i want to write everything to the 'currentState.pl' however when i consult the file i get this error, line 27 is the tell() method. Any help would be greatly appreciated.
.pl:27:24: Syntax error: Operator expected
saveState:-
tell(‘currentState.pl’),
listing(on),
listing(left),
listing(holding),
told,
write('Current State Saved'),nl.
I think it should be tell('currentState.pl'), instead of tell(‘currentState.pl’), ' instead of ‘ or ’
I can change prompt_alternatives_on flag in the REPL.
But how do I change this flag in .plrc?
Then I get
permission to modify static_procedure `set_prolog_flag/2'
Goal: To not get the "More?" text for all the answers all the time. By changing the flag.
Put :- (a colon and a hypen) in front of the line to execute it when the file is loaded.
:- set_prolog_flag(key, value).
This is true of any line of code in any source file that you want to have evaluated when the file is loaded instead of considered a new fact or rule (which causes the error because it attempts to redefine set_prolog_flag/2).