I am new to Prolog and noticed that ' and " give different behavior, but am curious as to why. Specifically, when loading a file, ?- ['test1.pl'].
works, while ?- ["test1.pl"].
doesn't.
相关问题
- Creating a SPARQL parameterized query using append
- Accommodate two types of quotes in a regex
- How to join rules and print out outputs in prolog
- Splitting list and iterating in prolog
- Accumulating while in recursion/backtracking
相关文章
- What are the problems associated to Best First Sea
- How can I fix this circular predicate in Prolog?
- How to negate in Prolog
- Remove incorrect subsequent solutions without once
- How do you embed double-quotes an Elixir string?
- prolog two lists are exactly the same
- Simplify Expressions in Prolog
- Check if any element's frequency is above a li
Strings in Prolog are written in single quotes. Terms written in double quotes are immediately converted to a list of character codes.
Single quoted items are always atoms.
The meaning of double quotes depends on the Prolog flag
double_quotes
:atom
— with this value"a" = a
. Nowadays, this is rarely used. But you will find Prolog books where["abc.pl"]
is written.codes
— a list of character codes. This is frequently the default, but it leads to very unreadable answers likeEven worse, if you use characters beyond ASCII:
chars
— a list of one-char atoms. See this for more about it.This notation gives more readable answers. It can be even more compactly displayed since the double quote notation can be used for printing any list of one-char atoms. There is
library(double_quotes)
for SICStus and SWI.If you have difficulties installing
double_quotes.pl
as a library, simply put it into the directory of your other Prolog files and say:use_module(double_quotes).