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

FunctionPurposeStatus
print(s)Print a str; adds no newline, so append "\n" yourselfVERIFIED
to_str(n)Convert an int to a stringVERIFIED
str_len(s)Length of a stringVERIFIED
substr(s, start, length)Part of a stringVERIFIED
str_byte(s, i)Byte value at an indexVERIFIED
str_eq(a, b)String equalityVERIFIED
list_new()Create a list[int] (capped at 512 elements)VERIFIED
push(l, v)Append to a listVERIFIED
get(l, i)Read element i; out of range aborts with exit 134VERIFIED
set(l, i, v)Overwrite element iVERIFIED
list_len(l)Number of elementsVERIFIED

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

FunctionPurposeStatus
math: abs_i, clamp, is_even, is_odd, gcdInteger helpersVERIFIED
fmath: abs_f, min_f, max_f, floor_f, ceil_f, round_f, pow_i, sqrt_f, fmt_f64Float helpersVERIFIED
strings: is_empty, is_blank, has, wrapString helpersVERIFIED
list: sum_list, max_in_list, count_ofList helpersVERIFIED
sort: sort_asc, is_sortedSort a list[int]VERIFIED
convert: int_to_str, str_to_int, bool_to_strConversionsVERIFIED
map: map_new, map_set, map_get, map_has, map_lenString key/value mapVERIFIED
time: unix_now, mono_now, elapsed_secsClock accessVERIFIED
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.