-
Notifications
You must be signed in to change notification settings - Fork 0
module std.string
Strings are immutable sequences of bytes. Spiral does not support Unicode, so there is no concept of a character (character literals are evaluated to their ASCII value).
-
(str? x)
returns true ifx
is a string. -
(str-len str)
returns the length ofstr
in bytes. -
(str-get str idx)
returns the byte at zero-basedidx
instr
. -
(stringify x)
returns a programmer-readable representation ofx
. Numbers are formatted as usual, strings are left intact, lists are written in parentheses and other structures are formatted in a similar way. -
(str-cat-<n> arg1 ... arg<n>)
concatenates the arguments (which must be strings) and returns a new string. There are versionsstr-cat-0
tostr-cat-8
. -
(str->int str)
tries to read an integer from stringstr
and returns that integer orfalse
if the string could not be parsed. -
(str->number str)
reads a number (integer or float) from the stringstr
or returnsfalse
. -
(str-cmp a b)
lexicographically compares stringsa
andb
and returns 0 if they are equal, a negative value ifa < b
or a positive value ifa > b
.