Standard Library Overview
70+ functions. Zero dependencies. Everything below works in both the bytecode VM and AOT runtimes.
Built-ins (no import needed)
Section titled “Built-ins (no import needed)”| Function | Signature | Description |
|---|---|---|
print |
print(v: T) |
Print without newline |
println |
println(v: T) |
Print with newline |
input |
input(prompt?: str) -> str |
Print a prompt and read a line |
typeof |
typeof(v: T) -> str |
Runtime type name |
str |
str(v: T) -> str |
Convert to string |
int |
int(v: T) |
Parse/convert to int (.none on failure) |
float |
float(v: T) |
Parse/convert to float (.none on failure) |
len |
len(v: T) -> int |
Length of array, string, dict or range |
range |
range(start?, stop, step?) |
Integer range |
map |
map(arr, f) -> [U] |
Apply a function to each element |
filter |
filter(arr, f) -> [T] |
Keep elements where predicate holds |
enumerate |
enumerate(arr) |
Index + value pairs |
zip |
zip(a, b) |
Pair elements from two iterables |
squares := map(range(1, 6), |x: int| x * x)evens := filter(range(1, 11), |x: int| x % 2 == 0)Modules
Section titled “Modules”Console output needs no import: print, println and input are core
built-ins (see Language Reference).
| Module | Purpose | Page |
|---|---|---|
std.str |
String manipulation | str |
std.vec |
Array operations | vec |
std.json |
JSON parsing/serialization | json |
std.http |
HTTP client + server | http |
std.fs |
Filesystem operations | fs |
std.env |
Environment variables, CLI args | env |
std.math |
Math functions | math |
std.time |
Time and sleep | time |
std.encoding |
Base64, hex, URL encoding | encoding |
std.net |
TCP networking | net |
import std.strimport std.mathMethod syntax
Section titled “Method syntax”str and vec functions double as methods on values:
import std.strimport std.vec
" hello ".trim() // "hello""hello".to_upper() // "HELLO"[3, 1, 2].sort() // [1, 2, 3]["a", "b"].join(", ") // "a, b"Option / Result methods
Section titled “Option / Result methods”Available on every variant value:
| Method | Description |
|---|---|
.unwrap() |
Unwrap or panic |
.unwrap_or(default) |
Unwrap or use default |
.expect(msg) |
Unwrap or panic with message |
x := .some(42)x.unwrap() // 42x.unwrap_or(0) // 42
y: Option<int> = .noney.unwrap_or(0) // 0
ok_val := .ok(42)ok_val.unwrap_or(0) // 42