Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

string

string is a module that provides functions for operating on strings

Functions


Prints the passed string to the console.

Example

# <span class='hljs-keyword'>module</span> demo = 
    <span class='hljs-keyword'>let</span> <span class='hljs-punctuation'>(</span><span class='hljs-punctuation'>)</span> = <span class='hljs-title class_'>string</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>print</span> <span class='hljs-string'>"Hi"</span>
    <span class='hljs-comment'>(* Prints "Hi" *)</span>
# <span class='hljs-keyword'>end</span>

length: string -> integer

Returns the length of the passed string.

Example

# <span class='hljs-keyword'>module</span> demo = 
    <span class='hljs-keyword'>let</span> my_int = <span class='hljs-title class_'>string</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>length</span> <span class='hljs-string'>"Hello"</span>
    <span class='hljs-comment'>(* my_int == 5 *)</span>
# <span class='hljs-keyword'>end</span>

concatenate: string -> string -> string

Adds the second string to the end of the first.

Example

# <span class='hljs-keyword'>module</span> demo = 
    <span class='hljs-keyword'>let</span> <span class='hljs-punctuation'>(</span><span class='hljs-punctuation'>)</span> = <span class='hljs-title class_'>string</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>concatenate</span> <span class='hljs-string'>"Kasane"</span> <span class='hljs-string'>" Teto"</span> <span class='hljs-operator'>|&gt;</span> <span class='hljs-title class_'>string</span><span class='hljs-punctuation'>::</span><span class='hljs-title function_'>print</span>
    <span class='hljs-comment'>(* prints "Kasane Teto" *)</span>
# <span class='hljs-keyword'>end</span>