Builtins
The functions that come with the language.
A builtin is a function the engine provides, so you call it inside any cell without declaring it. Every call on this page was run against the current toolchain before it was written down.
Text
| Call | Returns | Does |
|---|---|---|
| concat(a, b) | text | Join two strings. |
| len(s) | number | Length of a string, or the count of a list. |
| char_at(s, n) | text | One character, counted from 0, so char_at("voltage", 4) gives "a". |
| ord(s) | number | Character code: ord("A") gives 65. |
| chr(n) | text | Character for a code: chr(65) gives "A". |
Numbers
| Call | Returns | Does |
|---|---|---|
| abs(n) | number | Distance from zero. |
| floor(n) | number | Round down. |
| sqrt(n) | number | Square root. |
| max(a, b) | number | Larger of two. |
| min(a, b) | number | Smaller of two. |
| mod(a, b) | number | Remainder after division. |
Lists
A list is written with square brackets, and len() counts its items.
circuit f;
cell main() -> float {
let xs = [1.0, 2.0, 3.0];
print(len(xs));
emit 0.0;
}Prints 3.
Files
| Call | Returns | Does |
|---|---|---|
| read_file(path) | text | Whole file as one string. |
| write_file(path, text) | number | Writes the string. 1 on success. |
| read_bytes(path) | list | The file as a list of byte values. |
Screen
print(value) writes a value to the terminal. A whole number is written without a decimal point, so print(1.0) shows 1 and print(3.5) shows 3.5.
Time
now_ms is the clock in milliseconds since the epoch, as a number.
Neural
| Call | Returns | Does |
|---|---|---|
| nn_gelu(x) | number | GELU activation. |
| nn_softmax | list | Softmax over a list of scores. |
| nn_matvec | list | Matrix times vector. |
| nn_layernorm | list | Normalize a vector. |
| nn_argmax | number | Index of the largest value. |
GPU
| Call | Returns | Does |
|---|---|---|
| gpu_info | text | Name of the device the card path will use. |
| gpu_open | text | Opens the device and reports the plane layout. |
| gpu_load_file | number | Uploads a named file to the device. 1 on success. |
| gpu_matvec | list | Matrix times vector, run on the card, as in nn_matvec. |
| gpu_close | number | Releases the device. |
Framebuffer
Drawing calls, for a program that presents an image.
| Call | Does |
|---|---|
| fb_clear | Fill the target with one colour. |
| fb_pixel | Set one pixel: x, y, colour. |
| fb_line | Draw a line: x1, y1, x2, y2, colour. |
| fb_rect | Draw a rectangle: x, y, width, height, colour. |
| fb_text | Draw text: x, y, string, colour. |
| fb_get | Read one pixel: x, y. |
| fb_present | Show what has been drawn. |
Window
Calls for a program that opens its own window and reads the keyboard.
| Call | Does |
|---|---|
| win_open | Open a window: title, width, height. |
| win_poll | Pump messages, so the window stays responsive. |
| win_keycode | Last key pressed. |
| win_sleep_ms | Wait. |
| win_close | Close the window. |
Audio
write_wav(path, samples) writes a list of samples to a .wav file.