Global functions

global

Language-level builtins and default output functions available without an import.

These functions are available directly; no use declaration is required.

Functions

FunctionDescription
lenReturn the length of a string, array, or map.
sliceSlice a string from the given start and length.
concatConcatenate two strings.
array_newCreate an empty array.
array_pushAppend a value to an array and return the updated array.
map_newCreate an empty map.
getRead a string entry.
hasCheck whether an array contains a valid index.
typeReturn the runtime type name of a value.
setUpdate an array entry and return the updated array.
keysReturn an array of container keys or indices.
countReturn the number of entries in an array or map.
assertAbort execution if the condition is false.
string_containsReturn true when needle is found within text.
string_replace_literalReplace non-overlapping literal needle matches in text.
string_lower_asciiLower ASCII A-Z bytes in text while preserving UTF-8.
string_split_literalSplit text on non-overlapping literal delimiter matches.
printWrites a value to the runtime print sink.
printlnWrites a value to the runtime print sink and appends a newline.

Function details

len

fn len(text: string) -> int
fn len(items: array) -> int
fn len(items: bytes) -> int
fn len(entries: map) -> int

Return the length of a string, array, or map.

slice

fn slice(text: string, start: int, length: int) -> string
fn slice(items: array, start: int, length: int) -> array
fn slice(items: bytes, start: int, length: int) -> bytes

Slice a string from the given start and length.

concat

fn concat(left: string, right: string) -> string
fn concat(left: array, right: array) -> array
fn concat(left: bytes, right: bytes) -> bytes

Concatenate two strings.

array_new

fn array_new() -> array

Create an empty array.

array_push

fn array_push(items: array, value: any) -> array

Append a value to an array and return the updated array.

map_new

fn map_new() -> map

Create an empty map.

get

fn get(text: string, index: int) -> string
fn get(items: array, index: int) -> unknown
fn get(items: bytes, index: int) -> int
fn get(entries: map, key: any) -> unknown

Read a string entry.

has

fn has(items: array, index: int) -> bool
fn has(items: bytes, index: int) -> bool
fn has(entries: map, key: any) -> bool

Check whether an array contains a valid index.

type

fn type(value: any) -> string

Return the runtime type name of a value.

set

fn set(items: array, index: int, value: any) -> array
fn set(entries: map, key: any, value: any) -> map

Update an array entry and return the updated array.

keys

fn keys(items: array) -> array
fn keys(entries: map) -> array

Return an array of container keys or indices.

count

fn count(items: array) -> int
fn count(entries: map) -> int

Return the number of entries in an array or map.

assert

fn assert(condition: bool) -> null

Abort execution if the condition is false.

string_contains

fn string_contains(text: string, needle: string) -> bool

Return true when needle is found within text.

string_replace_literal

fn string_replace_literal(text: string, needle: string, replacement: string) -> string

Replace non-overlapping literal needle matches in text.

string_lower_ascii

fn string_lower_ascii(text: string) -> string

Lower ASCII A-Z bytes in text while preserving UTF-8.

string_split_literal

fn string_split_literal(text: string, delimiter: string) -> array

Split text on non-overlapping literal delimiter matches.

print

fn print(value: any) -> any

Writes a value to the runtime print sink.

println

fn println(value: any) -> any

Writes a value to the runtime print sink and appends a newline.