-
Notifications
You must be signed in to change notification settings - Fork 0
Strings and Chars
Strings are lists of chars.
Given we have lists, it makes sense to avail ourselves of them to implement strings. So for example:
"Hello," @@ " world!"
and
list.length("hello")
both work, and we get those, and all the other list operations on strings for free.
See Lists for @@ etc.
We use the C convention
of single quotes ('a') to delimit chars and double quotes ("hello!") to delimit strings, so
'H' @ "ello"
is how to build strings from chars, and
['H', 'i']
prints as "Hi".
The language has basic Unicode support. Unicode characters outside of the ASCII range can be used in variable names
and in literal strings and characters. Currently the only supported encoding for input and output is UTF-8. Unicode escape sequences
of the form \uxxx; (where xxx is one or more hexadecimal digits) can also be used in strings and characters.
Here's a small example from the tests.
let
link "listutils.fn" as list;
Σ = "abc\u03b1;\u03b2;\u03b3;";
Ψ = "abcαβγ";
F♮ = "cool";
in
assert(list.length(Σ) == 6);
assert(list.length(Ψ) == 6);
assert(Σ == Ψ);
assert('\u03b1;' == 'α');
assert(F♮ == "cool");
Next: Tuples

CEKF(s) a.k.a. F Natural a.k.a F♮