Skip to content
Jan Špaček edited this page Apr 12, 2016 · 1 revision

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 if x is a string.

  • (str-len str) returns the length of str in bytes.

  • (str-get str idx) returns the byte at zero-based idx in str.

  • (stringify x) returns a programmer-readable representation of x. 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 versions str-cat-0 to str-cat-8.

  • (str->int str) tries to read an integer from string str and returns that integer or false if the string could not be parsed.

  • (str->number str) reads a number (integer or float) from the string str or returns false.

  • (str-cmp a b) lexicographically compares strings a and b and returns 0 if they are equal, a negative value if a < b or a positive value if a > b.