Built-in Functions
Reference for all built-in functions and their usage.
Input / Output Functions
print(value)
Output a value to stdout followed by a newline.
print("Hello, World!")
print(42)
print([1, 2, 3])
Returns null. Accepts any value.
input<str>(prompt)
Read a string from standard input after displaying a string prompt.
set name = input<str>("Enter name: ")
print(name)
Returns the trimmed input string.
input<int>(prompt)
Read an integer from standard input after displaying a string prompt.
set age = input<int>("Age: ")
print(age + 1)
Returns an integer. Invalid input is rejected and the program prompts again.
input<float>(prompt)
Read a floating-point number from standard input after displaying a string prompt.
set price = input<float>("Price: ")
print(price * 1.1)
Returns a double-precision float. Invalid and non-finite input is rejected.
input<int|float|str>(prompt)
Accept an integer, float, or text value. Kria tries integer parsing, then float parsing, then accepts text that does not parse as a number.
set value = input<int|float|str>("Value: ")
print(type(value))
Type Checking
type(value)
Get the type of a value as a string.
print(type(42))
print(type("hello"))
print(type(true))
print(type(null))
print(type([1, 2, 3]))
print(type(#[1, 2]))
print(type({ x: 1 }))
print(type(fn(x) { return x }))
Returns one of: "number", "string", "boolean",
"null", "array", "object", or "function".
Integers and floats both report as "number".
Timing Functions
wait(milliseconds)
Pause execution for a specified number of milliseconds.
print("Starting pause...")
wait(500)
print("Done (half a second later)")
Useful for delays, animations, or rate-limiting.
Returns null.
Example: Timed Loop
set i = 0
while (i < 3) {
print(i)
wait(200)
set i = i + 1
}
Array Operations
push(array, value)
Add an element to the end of a mutable array.
set arr = [1, 2, 3]
push(arr, 4)
print(arr)
Modifies the array in place. Returns null.
pop(array)
Remove and return the last element of a mutable array.
set arr = [1, 2, 3]
set last = pop(arr)
print(last)
print(arr)
Returns the removed element. Popping an empty array is an error.
.length property
Get the number of elements in an array.
set arr = [10, 20, 30]
print(arr.length)
Works for both mutable and immutable arrays.
Object Operations
rmv(property)
Delete a property from an object.
set user = { name: "Kria", age: 5 }
rmv(user.name)
print(user.name)
After removal, the property returns null.
Also works with bracket notation: rmv(user["name"]).
Comments & Strings
Single-line Comments
// This is a comment
set x = 10 // Inline comment
Everything after // on a line is ignored.
Block Comments
/*
Multi-line comment
spans multiple lines
*/
print("visible")
Nested block comments are not supported.
Multi-line Strings
print("""Line one
Line two
Line three""")
Use triple quotes """ for strings spanning multiple lines.