Reference / Built-in Functions Reference
Built-in Functions Reference
Output
print(x) | prints a value (integers output directly, no newline) |
print("fmt", a, b, ...) | format-string printing: %d integers, %s strings |
Assertions
assert(cond) | prints diagnostics and terminates if false (non-zero exit code) |
assert_eq(a, b) | terminates with failure if not equal |
Strings
len(s) | byte length |
s1 + s2 | concatenation |
s[i] | numeric value of the i-th byte |
int_to_str(n) | integer → string (needs str_free) |
str_to_int(s) | string → integer (returns 0 on failure) |
substr(s, start, end) | slice [start, end) (needs str_free) |
str_contains(h, n) | contains (bool) |
str_find(h, n) | first occurrence position, -1 if not found |
str_cmp(a, b) | C-style comparison |
str_free(s) | frees a runtime-allocated string |
Numbers / Math
matmul(a, b) | 2D tensor matrix multiplication (dimensions checked at compile time) |
format("%f", x) | float formatting |
hash_i64(k) | integer hash |
str_hash(s) | string hash |
Files & Command Line
read_file(path) | reads the whole file as a string, returns empty string on failure |
write_file(path, contents) | writes a file, returns the byte count, -1 on failure |
arg_count() | total number of command-line arguments (including the program name) |
arg(i) | the i-th argument, empty string when out of bounds |
Paths (Standard Library)
path_join / path_basename / path_dirname / path_extension — return an owned String, separator /, consistent across platforms.
JSON (Standard Library, Zero-Dependency)
Encode: json_escape(s), json_string(s), json_number_i64(v), json_number_f64(v), json_bool(b), json_null(), json_join(a, sep, b)Decode: json_parse_i64(s), json_parse_bool(s), json_unescape(s), json_find_key(s, key)AI
tensor(rows, cols), matmul(a, b), automatic differentiation grad_new / g_leaf / g_add / g_mul / g_neg / g_inv / g_sub / g_div / g_backward / g_grad / g_val