Core Functions
I/O operations, type conversion, array/hash manipulation, string functions, and math utilities.
I/O Functions
print(value)
Prints a value to standard output without a newline.
print("Hello")
print(" World") // Output: Hello World
input(prompt?)
Reads a line of input from the user. Returns the user's input as a String.
let name = input("Enter your name: ")
println("Hello, " + name)
Type Functions
type(value)
Returns the type name of a value as a string.
type(42) // "int"
type("hello") // "string"
type([1, 2, 3]) // "array"
type(null) // "null"
len(value)
Returns the length of a string, array, or hash.
len("hello") // 5
len([1, 2, 3]) // 3
len({"a": 1}) // 1
Array Functions
push(array, value)
Add an element to the end of an array.
let arr = [1, 2]
push(arr, 3) // arr is now [1, 2, 3]
pop(array)
Remove and return the last element from an array.
let arr = [1, 2, 3]
let last = pop(arr) // last is 3, arr is [1, 2]
range(start, end, step?)
Creates an array of numbers from start to end (exclusive).
range(0, 5) // [0, 1, 2, 3, 4]
range(1, 10, 2) // [1, 3, 5, 7, 9]
range(5, 0, -1) // [5, 4, 3, 2, 1]
Hash Functions
keys(hash)
Returns an array of all keys in a hash.
let h = {"name": "Alice", "age": 30}
keys(h) // ["name", "age"]
values(hash)
Returns an array of all values in a hash.
let h = {"name": "Alice", "age": 30}
values(h) // ["Alice", 30]
entries(hash)
Returns an array of [key, value] pairs.
let h = {"name": "Alice", "age": 30}
entries(h) // [["name", "Alice"], ["age", 30]]
has_key(hash, key)
Check if a key exists in a hash.
has_key({"a": 1}, "a") // true
has_key({"a": 1}, "b") // false
String Functions
upcase(str) / downcase(str) / trim(str)
Transform string case and whitespace.
upcase("hello") // "HELLO"
downcase("HELLO") // "hello"
trim(" hi ") // "hi"
replace(str, from, to)
Replace all occurrences of a substring.
replace("hello world", "world", "soli") // "hello soli"
html_escape(str) / html_unescape(str) / sanitize_html(str)
HTML encoding and security functions.
html_escape("<script>") // "<script>"
html_unescape("<p>") // "<p>"
sanitize_html("<p onclick='x'>") // "<p>"
Math Functions
clock()
Returns the current Unix timestamp as a float with sub-second precision.
let start = clock()
// ... do work ...
let elapsed = clock() - start