VolkanaDEV

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

CallReturnsDoes
concat(a, b)textJoin two strings.
len(s)numberLength of a string, or the count of a list.
char_at(s, n)textOne character, counted from 0, so char_at("voltage", 4) gives "a".
ord(s)numberCharacter code: ord("A") gives 65.
chr(n)textCharacter for a code: chr(65) gives "A".

Numbers

CallReturnsDoes
abs(n)numberDistance from zero.
floor(n)numberRound down.
sqrt(n)numberSquare root.
max(a, b)numberLarger of two.
min(a, b)numberSmaller of two.
mod(a, b)numberRemainder 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

CallReturnsDoes
read_file(path)textWhole file as one string.
write_file(path, text)numberWrites the string. 1 on success.
read_bytes(path)listThe 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

CallReturnsDoes
nn_gelu(x)numberGELU activation.
nn_softmaxlistSoftmax over a list of scores.
nn_matveclistMatrix times vector.
nn_layernormlistNormalize a vector.
nn_argmaxnumberIndex of the largest value.

GPU

CallReturnsDoes
gpu_infotextName of the device the card path will use.
gpu_opentextOpens the device and reports the plane layout.
gpu_load_filenumberUploads a named file to the device. 1 on success.
gpu_matveclistMatrix times vector, run on the card, as in nn_matvec.
gpu_closenumberReleases the device.

Framebuffer

Drawing calls, for a program that presents an image.

CallDoes
fb_clearFill the target with one colour.
fb_pixelSet one pixel: x, y, colour.
fb_lineDraw a line: x1, y1, x2, y2, colour.
fb_rectDraw a rectangle: x, y, width, height, colour.
fb_textDraw text: x, y, string, colour.
fb_getRead one pixel: x, y.
fb_presentShow what has been drawn.

Window

Calls for a program that opens its own window and reads the keyboard.

CallDoes
win_openOpen a window: title, width, height.
win_pollPump messages, so the window stays responsive.
win_keycodeLast key pressed.
win_sleep_msWait.
win_closeClose the window.

Audio

write_wav(path, samples) writes a list of samples to a .wav file.