Built-in Functions

Vortex provides some built-in native functions. We'll cover those off here:

// Prints the provided arguments to the console.
const print = (...args) => None

// Prints the provided arguments to the console, followed by a newline.
const println = (...args) => None

// Returns the current system time in milliseconds.
const clock = () => Number

// Converts the provided value to a string.
const string = (v: Any) => String

// Converts the provided value to a number, if possible.
const number = (v: Any) => Number | None

// Inserts a value into a list at the specified position and returns the modified list.
const insert = (ls: List, v: Any, pos: Number) => List

// Appends a value to a list and returns the modified list.
const append = (ls: List, v: Any) => List

// Removes an element from a list at the specified position and returns the modified list.
const remove = (ls: List, pos: Number) => List

// Removes a property from an object and returns the modified object.
const remove_prop = (obj: Object, key: String) => Object

// Returns the length of the provided value if it is iterable.
const length = (v: Any) => Number | None

/* 
Returns information about the provided value. The object returned has different properties based on what value type you are inspecting.

As an example, calling info() on an object allows you to access its keys and values:

    info(obj).keys -> [String] 
    info(obj).values -> [Any] 
*/
const info = (v: Any) => Object

// Returns the type of the provided value as a string.
const type = (v: Any) => String

// Sorts a list using the provided comparison function and returns the sorted list.
const sort = (ls: List, fn: Function) => List

// Creates a shallow copy of the provided value.
const copy = (v: Any) => Any

// Returns the provided value with all hooks removed.
const pure = (v: Any) => Any

// Disassembles the bytecode of the provided function and prints it.
const dis = (fn: Function) => None

// Exits the program with the provided exit code.
const exit = (value: Number) => Number

// Creates and returns an error object with the specified message and error type.
const error = (message: String, error_type: String = "GenericError") => Object

// Similar to 'error', but returns an error object without throwing an exception.
const Error = (message: String, error_type: String = "GenericError") => Object

// Launches the provided function in a new thread and provides the C++ future pointer
const __future__ = (func: Function, vm: Pointer) => Pointer

// Retrieves of the value from the provided Future
const __get_future__ = (future_ptr: Pointer) => Any

// Checks if the Future value is ready for retrieval
const __check_future__ = (future_ptr: Pointer) => Boolean

// Loads a library from the specified path and returns the exposed functions as an object.
const load_lib = (path: String, func_list: [String]) => Object

Last updated