Literals/String: Difference between revisions

Line 2,023:
Same as above, but no interpolation of $variables.
END;</lang>
 
=={{header|Picat}}==
A string is a list of characters. The string literal is in double quotes (a character is in single quote, e.g 's'):
<pre>"string"</pre>
 
It can also be constructed as a list of characters:
<pre>['s','t','r','i','n','g']</pre>
 
or as a list of (character) atoms (without single quotes):
<pre>[s,t,r,i,n,g]</pre>
 
However, upper case characters must be quoted (otherwise they are considered variables):
<pre>['S',t,r,i,n,g]</pre>
 
 
Quoting of certain characters are with an escape character (<code>\c</code>):
 
<pre>"a string\'s quotes: \"a string\'s quotes\". Spaces: \t\n\l\r"</pre>
 
A string can be written on several lines where the newlines are kept:
<lang Picat> X = "string with
newlines and
spaces",
% ...
</lang>
 
Using a single <code>\</code> as the last character on a line makes the line continue without newline.
<lang Picat> X = "string with \
newlines \
and \
spaces",
% ...
</lang>
 
is the same as
<pre>string with newlines and spaces</pre>
 
 
=={{header|PicoLisp}}==
495

edits