Standard Library
This reference lists the built-ins and the std modules of the self-hosted RUDRA 1.1.0 release. Every function named here was compiled and run with the shipped compiler. The release includes 68 modules; this page covers the core ones.
Core built-ins
| Function | Purpose | Status |
|---|---|---|
print(s) | Print a str; adds no newline, so append "\n" yourself | VERIFIED |
to_str(n) | Convert an int to a string | VERIFIED |
str_len(s) | Length of a string | VERIFIED |
substr(s, start, length) | Part of a string | VERIFIED |
str_byte(s, i) | Byte value at an index | VERIFIED |
str_eq(a, b) | String equality | VERIFIED |
list_new() | Create a list[int] (capped at 512 elements) | VERIFIED |
push(l, v) | Append to a list | VERIFIED |
get(l, i) | Read element i; out of range aborts with exit 134 | VERIFIED |
set(l, i, v) | Overwrite element i | VERIFIED |
list_len(l) | Number of elements | VERIFIED |
Importing std modules
Add import "module"; at the top of a file. ruxc resolves imports only from the source file's own directory, so compile programs that import std modules with rudra file.rux output, which copies the std library next to a temporary copy of your source first.
Common modules
| Function | Purpose | Status |
|---|---|---|
math: abs_i, clamp, is_even, is_odd, gcd | Integer helpers | VERIFIED |
fmath: abs_f, min_f, max_f, floor_f, ceil_f, round_f, pow_i, sqrt_f, fmt_f64 | Float helpers | VERIFIED |
strings: is_empty, is_blank, has, wrap | String helpers | VERIFIED |
list: sum_list, max_in_list, count_of | List helpers | VERIFIED |
sort: sort_asc, is_sorted | Sort a list[int] | VERIFIED |
convert: int_to_str, str_to_int, bool_to_str | Conversions | VERIFIED |
map: map_new, map_set, map_get, map_has, map_len | String key/value map | VERIFIED |
time: unix_now, mono_now, elapsed_secs | Clock access | VERIFIED |
import "math";
import "strings";
import "sort";
import "list";
import "convert";
fn main() -> int {
let xs = list_new();
push(xs, 5);
push(xs, 2);
push(xs, 9);
let ys = sort_asc(xs);
print(to_str(get(ys, 0)) + " " + to_str(get(ys, 2)) + "\n");
print(to_str(sum_list(xs)) + "\n");
print(to_str(max_in_list(xs)) + "\n");
print(to_str(gcd(12, 18)) + "\n");
print(to_str(clamp(15, 0, 10)) + "\n");
print(to_str(str_to_int("42") + 1) + "\n");
if has("hello world", "world") {
print("found\n");
}
return 0;
}
return main(); Output:
2 9
16
9
6
10
43
found Not built-ins
There are no spawn, mutex_new, chan_new, http_get or json_get built-ins, no built-in len, and no built-in Option/Result or ?. Modules named thread, chan, net, http, json and tls13* exist in the std directory with documented limits, but they are library code, not language built-ins, and are not documented as verified here. TLS transport is not wired into a live authenticated HTTPS client.