ns std
/// Less.
fn less(a: any, b: any) -> bool { ... }
(sec[f64], f64) -> sec[bool]
(f64, f64) -> bool
(str, str) -> bool
/// Less or equal.
fn less_or_equal(a: any, b: any) -> bool { ... }
(sec[f64], f64) -> sec[bool]
(f64, f64) -> bool
(str, str) -> bool
/// Greater.
fn greater(a: any, b: any) -> bool { ... }
(sec[f64], f64) -> sec[bool]
(f64, f64) -> bool
(str, str) -> bool
/// Greater or equal.
fn greater_or_equal(a: any, b: any) -> bool { ... }
(sec[f64], f64) -> sec[bool]
(f64, f64) -> bool
(str, str) -> bool
/// Equal.
fn equal(a: any, b: any) -> bool { ... }
(sec[f64], f64) -> sec[bool]
(f64, f64) -> bool
(str, str) -> bool
(sec[bool], bool) -> sec[bool]
(bool, bool) -> bool
(vec4, vec4) -> bool
({}, {}) -> bool
([], []) -> bool
(opt, opt) -> bool
/// Not equal.
fn not_equal(a: any, b: any) -> bool { ... }
(sec[f64], f64) -> sec[bool]
(f64, f64) -> bool
(str, str) -> bool
/// Lazy AND (`&&`).
fn and_also(a: bool => false, b: bool) -> any { ... }
(sec[bool], bool) -> sec[bool]
(bool, bool) -> bool
/// Lazy OR (`||`).
fn or_else(a: bool => true, b: bool) -> any { ... }
(sec[bool], bool) -> sec[bool]
(bool, bool) -> bool
/// Returns an array of derived information for the truth value of `var`.
/// This can be used with the value of `∃`/`any` and `∀`/`all` loops.
fn why(var: sec[bool]) -> [any] { ... }
/// Returns an array of derived information for the value of `var`.
/// This can be used with the value of `min` and `max` loops.
fn where(var: sec[f64]) -> [any] { ... }
/// Adds message to derived information for the truth value of `var`.
/// This can be used with the value of `∃`/`any` and `∀`/`all` loops.
fn explain_why(var: bool, msg: any) -> sec[bool] { ... }
/// Adds message to derived information for the value of `var`.
/// This can be used with the value of `min` and `max` loops.
fn explain_where(var: f64, msg: any) -> sec[f64] { ... }
/// Prints out variable to standard output, adding newline character.
fn println(var: any) { ... }
/// Prints out variable to standard output.
fn print(var: any) { ... }
/// Prints out variable to standard error, adding newline character.
fn eprintln(var: any) { ... }
/// Prints out variable to standard error.
fn eprint(var: any) { ... }
/// Clones the variable and all references it contains.
fn clone(var: any) -> any { ... }
/// Prints out the state of stack and local stack.
fn debug() { ... }
/// Prints out call stack.
fn backtrace() { ... }
/// Returns `true` if link is empty.
fn is_empty(l: link) -> bool { ... }
/// Returns the first item in a link.
fn head(l: link) -> opt[any] { ... }
/// Returns the whole link except first item.
fn tail(l: link) -> link { ... }
/// Returns the last item in a link.
fn tip(l: link) -> opt[any] { ... }
/// Returns the whole link except last item.
fn neck(l: link) -> link { ... }
/// Sleeps for a given amount of seconds.
fn sleep(seconds: f64) { ... }
/// Returns a random number between 0 and 1.
fn random() -> f64 { ... }
/// Reads a number from standard input with a message to the user.
/// If the input is in invalid format, it reports the error to the user,
/// and then asks again.
fn read_number(message: str) -> f64 { ... }
/// Parses number from string.
fn parse_number(text: str) -> opt[f64] { ... }
/// Reads a line from standard input.
fn read_line() -> str { ... }
/// Returns the length of array.
fn len(array: [any]) -> f64 { ... }
/// Appends an item at end of array.
fn push_ref(mut array: [any], item: 'array any) { ... }
/// Appends a deep clone of an item at end of array.
fn push(mut array: [any], item: any) { ... }
/// Inserts item at index in array.
fn insert_ref(mut array: [any], index: f64, item: 'array any) { ... }
/// Inserts a deep clone of an item at index in array.
fn insert(mut array: [any], index: f64, item: 'array any) { ... }
/// Removes last item from array.
fn pop(mut array: 'return [any]) -> any { ... }
/// Removes item from array at index.
fn remove(mut array: 'return [any], index: f64) -> any { ... }
/// Reverses the items in array.
fn reverse(mut array: [any]) { ... }
/// Removes all items from array.
fn clear(mut array: [any]) { ... }
/// Swaps two items in array.
fn swap(mut array: [any], i: f64, j: f64) { ... }
/// Returns a string with removed whitespace on both sides.
fn trim(text: str) -> str { ... }
/// Returns a string with removed whitespace at left side.
fn trim_left(text: str) -> str { ... }
/// Returns a string with removed whitespace at right side.
fn trim_right(text: str) -> str { ... }
/// Returns a string representation of variable.
fn str(var: any) -> str { ... }
/// Formats text with newlines and tab shifts using spaces.
fn fmt__tab_string(tab: f64, text: str) -> str { ... }
/// Creates a JSON string of text.
fn json_string(text: str) -> str { ... }
/// Returns a HTML hex color string.
/// The vector is clamped in range `(0, 0, 0, 0)` to `(1, 1, 1, 1).
fn str__color(color: vec4) -> str { ... }
/// Converts from sRGB color space to linear color space.
/// This is used before mathematical operations on colors.
fn srgb_to_linear__color(color: vec4) -> vec4 { ... }
/// Converts from linear color space to sRGB.
/// This is used after mathematical operations on colors.
fn linear_to_srgb__color(color: vec4) -> vec4 { ... }
/// Returns simple description of variable type.
fn typeof(var: any) -> str { ... }
/// Rounds number, e.g. `round(0.5) == 1.0`.
fn round(v: f64) -> f64 { ... }
/// Returns absolute value, e.g. `abs(-3) == 3`.
fn abs(v: f64) -> f64 { ... }
/// Returns the highest smaller integer, e.g. `floor(3.2) == 3.0`.
fn floor(v: f64) -> f64 { ... }
/// Returns the smallest higher integer, e.g. `ceil(3.2) == 4.0`.
fn ceil(v: f64) -> f64 { ... }
/// Returns the square root of number.
fn sqrt(v: f64) -> f64 { ... }
/// Returns the sinus of number.
fn sin(v: f64) -> f64 { ... }
/// Returns the inverse sinus of number.
fn asin(v: f64) -> f64 { ... }
/// Returns the cosinus of number.
fn cos(v: f64) -> f64 { ... }
/// Returns the inverse cosinus of number.
fn acos(v: f64) -> f64 { ... }
/// Returns the tangent of number in radians.
fn tan(v: f64) -> f64 { ... }
/// Returns the inverse tangent of number in radians.
fn atan(v: f64) -> f64 { ... }
/// Returns the inverse tangent in radians.
fn atan2(y: f64, x: f64) -> f64 { ... }
/// Returns the natural exponential of number.
/// In mathematics this is often written as `e^x`.
fn exp(v: f64) -> f64 { ... }
/// Returns the natural logarithm of number.
fn ln(v: f64) -> f64 { ... }
/// Returns the logarithm of number with base 2.
fn log2(v: f64) -> f64 { ... }
/// Returns the logarithm of number with base 10.
fn log10(v: f64) -> f64 { ... }
/// Loads module from source.
/// Returns `ok(module)` if the loading succeeds.
fn load(source: str) -> res[any] { ... }
/// Loads module from source, using imports as dependencies.
/// Returns `ok(module)` if the loading succeeds.
fn load__source_imports(source: str, imports: [any]) -> res[any] { ... }
/// Loads module from source, using imports as dependencies.
/// Returns `ok(module)` if the loading succeeds.
///
/// - `tr`: Whether the loaded module is transitive
/// - `usetr`: Whether transitivity is enabled
fn load__source_imports_tr_usetr(
source: str, imports: [any], tr: bool, usetr: bool
) -> res[any] { ... }
/// Creates module from string.
/// Returns `ok(module)` if it succeeds.
fn module__in_string_imports(name: str, code: str, imports: [any]) -> res[any] { ... }
/// Creates module from string.
/// Returns `ok(module)` if it succeeds.
///
/// - `tr`: Whether the loaded module is transitive
/// - `usetr`: Whether transitivity is enabled
fn module__in_string_imports_tr_usetr(
name: str, code: str, imports: [any], tr: bool, usetr: bool
) -> res[any] { ... }
/// Returns data from lifetime/type-checker from source.
/// Ignores any lifetime or type error.
/// Returns an error if there are any syntax errors.
fn check__in_string_imports(name: str, code: str, imports: [any]) -> res[[{}]] { ... }
/// Returns data from lifetime/type-checker from source.
/// Ignores any lifetime or type error.
/// Returns an error if there are any syntax errors.
///
/// - `usetr`: Whether transitivity is enabled
fn check__in_string_imports_usetr(
name: str, code: str, imports: [any], usetr: bool
) -> res[[{}]] { ... }
/// Calls function in module with arguments.
fn call(module: any, function: str, arguments: [any]) { ... }
/// Calls function in module with arguments and returns the result.
fn call_ret(module: any, function: str, arguments: [any]) -> any { ... }
/// Returns list of available functions, sorted by name.
fn functions() -> any { ... }
/// Returns list of available functions from within module, sorted by name.
fn functions__module(module: any) -> any { ... }
/// Creates `none()` variant of option values.
fn none() -> opt[any] { ... }
/// Creates `some(var)` variant of option values.
fn some(var: any) -> opt[any] { ... }
/// Unwraps value of `some(x)` or `ok(x)`.
fn unwrap(var: any) -> any { ... }
/// Unwraps error from `err(x)`.
fn unwrap_err(var: any) -> any { ... }
/// Unwraps value or using a default.
///
/// This function uses a lazy invariant in the first argument.
/// This means that if the lazy invariant matches,
/// the second argument is not evaluated.
fn unwrap_or(var: any => ok(_) | some(_), def: any) -> any { ... }
/// Creates `ok(var)` variant of option values.
fn ok(var: any) -> res[any] { ... }
/// Creates `err(var)` variant of result values.
fn err(var: any) -> res[any] { ... }
/// Returns `true` if `err(x)`.
fn is_err(var: res[any]) -> bool { ... }
/// Returns `true` if `ok(x)`.
fn is_ok(var: res[any]) -> bool { ... }
/// Returns smallest number in non-empty array.
/// Returns NaN if array is empty.
fn min(array: [f64]) -> f64 { ... }
/// Returns highest number in non-empty array.
/// Returns NaN if array is empty.
fn max(array: [f64]) -> f64 { ... }
/// Addition.
fn add(a: any, b: any) -> any { ... }
all T { (T f64, T f64) -> T f64 }
all T { (T vec4, T vec4) -> T vec4 }
all T { (T vec4, T f64) -> T vec4 }
all T { (T f64, T vec4) -> T vec4 }
all T { (T mat4, T mat4) -> T mat4 }
all T { (T f64, T mat4) -> T mat4 }
all T { (T mat4, T f64) -> T mat4 }
all T { (T bool, T bool) -> T bool }
all T { (T str, T str) -> T str }
all T { (T link, T link) -> T link }
/// Subtraction.
fn sub(a: any, b: any) -> any { ... }
all T { (T f64, T f64) -> T f64 }
all T { (T vec4, T vec4) -> T vec4 }
all T { (T vec4, T f64) -> T vec4 }
all T { (T f64, T vec4) -> T vec4 }
all T { (T mat4, T mat4) -> T mat4 }
all T { (T f64, T mat4) -> T mat4 }
all T { (T mat4, T f64) -> T mat4 }
all T { (T bool, T bool) -> T bool }
/// Multiplication.
fn mul(a: any, b: any) -> any { ... }
(f64, f64) -> f64
(vec4, vec4) -> vec4
(vec4, f64) -> vec4
(f64, vec4) -> vec4
(mat4, mat4) -> mat4
(f64, mat4) -> mat4
(mat4, f64) -> mat4
(mat4, vec4) -> vec4
all T { (T bool, T bool) -> T bool }
/// Division.
fn div(a: any, b: any) -> any { ... }
(f64, f64) -> f64
(vec4, vec4) -> vec4
(vec4, f64) -> vec4
(f64, vec4) -> vec4
/// Division reminder.
fn rem(a: any, b: any) -> any { ... }
(f64, f64) -> f64
(vec4, vec4) -> vec4
(vec4, f64) -> vec4
(f64, vec4) -> vec4
/// Power operator.
fn pow(a: any, b: any) -> any { ... }
(f64, f64) -> f64
(vec4, vec4) -> vec4
(vec4, f64) -> vec4
(f64, vec4) -> vec4
all T { (T bool, T bool) -> T bool }
/// Returns the length of 4D vector.
fn norm(v: vec4) -> f64 { ... }
/// Logical NOT.
fn not(b: any) -> any { ... }
(sec[bool]) -> sec[bool]
(bool) -> bool
/// Negation.
fn neg(v: any) -> any { ... }
(f64) -> f64
(vec4) -> vec4
(mat4) -> mat4
/// Returns dot product.
fn dot(a: any, b: any) -> f64 { ... }
(vec4, vec4) -> f64
(vec4, f64) -> f64
(f64, vec4) -> f64
/// Returns cross product.
fn cross(a: vec4, b: vec4) -> vec4 { ... }
/// Returns x component of 4D vector.
fn x(v: vec4) -> f64 { ... }
/// Returns y component of 4D vector.
fn y(v: vec4) -> f64 { ... }
/// Returns z component of 4D vector.
fn z(v: vec4) -> f64 { ... }
/// Returns w component of 4D vector.
fn w(v: vec4) -> f64 { ... }
/// Returns component scalar of 4D vector by index.
fn s(v: vec4, ind: f64) -> f64 { ... }
/// Returns row vector x (basis vector) of 4D matrix.
fn rx(m: mat4) -> vec4 { ... }
/// Returns row vector y (basis vector) of 4D matrix.
fn ry(m: mat4) -> vec4 { ... }
/// Returns row vector z (basis vector) of 4D matrix.
fn rz(m: mat4) -> vec4 { ... }
/// Returns row vector w (basis vector) of 4D matrix.
fn rw(m: mat4) -> vec4 { ... }
/// Returns row vector (basis vector) of 4D matrix by index.
fn rv(m: mat4, ind: f64) -> vec4 { ... }
/// Returns column vector x (transposed basis vector) of 4D matrix.
fn cx(m: mat4) -> vec4 { ... }
/// Returns column vector y (transposed basis vector) of 4D matrix.
fn cy(m: mat4) -> vec4 { ... }
/// Returns column vector z (transposed basis vector) of 4D matrix.
fn cz(m: mat4) -> vec4 { ... }
/// Returns column vector (transposed basis vector) of 4D matrix by index.
fn cv(m: mat4) -> vec4 { ... }
/// Returns determinant of 4D matrix.
fn det(m: mat4) -> f64 { ... }
/// Returns the inverse of 4D matrix.
fn inv(m: mat4) -> mat4 { ... }
/// Returns a translation 4D matrix.
/// Ignores the 4th component.
fn mov(v: vec4) -> mat4 { ... }
/// Returns rotation 4D matrix around an axis and angle.
/// The angle is in radians.
fn rot__axis_angle(axis: vec4, angle: f64) -> mat4 { ... }
/// Returns orthogonal view 4D matrix from position and axis vectors.
fn ortho__pos_right_up_forward(pos: vec4, right: vec4, up: vec4, forward: vec4) -> mat4 { ... }
/// Returns projection 4D matrix from field of view, near clip, far clip and aspect ratio.
/// The field of view is in fractions, usually 1/4.
/// The aspect ratio is usually the width of the draw buffer divided by the height.
fn proj__fov_near_far_ar(fov: f64, near: f64, far: f64, ar: f64) -> mat4 { ... }
/// Returns model view projection 4D matrix.
fn mvp__model_view_projection(model: mat4, view: mat4, projection: mat4) -> mat4 { ... }
/// Returns a scale 4D matrix from a vector.
/// Ignores the 4th component.
fn scale(v: vec4) -> mat4 { ... }
/// Returns 4D vector with length 1,
/// pointing in the direction when starting at `(1, 0)`
/// and rotating around the z axis.
fn dir__angle(angle: f64) -> vec4 { ... }
/// Returns the number of radians in a circle.
/// Use this instead of pi (`tau == 2 * pi`).
fn tau() -> f64 { ... }
/// Loads meta data from a file, using a meta syntax to parse the document.
/// The meta language used is [Piston-Meta](https://github.com/PistonDevelopers/meta).
///
/// Returns an array of arrays:
///
/// - Start character
/// - Number of characters
/// - Type of meta data
/// -- "start" Start of node
/// -- "end" End of node
/// -- "str" -> `str`
/// -- "num" -> `f64`
/// -- "bool" -> `bool`
/// - Name of property
/// - Value
fn load__meta_file(meta_file: str, file: str) -> res[[[any]]] { ... }
/// Loads meta data from an url, using a meta syntax to parse the document.
/// The meta language used is [Piston-Meta](https://github.com/PistonDevelopers/meta).
///
/// For information about fields, see `load__meta_file`.
fn load__meta_url(meta_file: str, url: str) -> res[[any]] { ... }
/// Parses meta syntax rules from string.
/// The meta language used is [Piston-Meta](https://github.com/PistonDevelopers/meta).
fn syntax__in_string(name: str, text: str) -> res[any] { ... }
/// Parses meta data from string.
fn meta__syntax_in_string(syntax: any, name: str, text: str) -> res[[any]] { ... }
/// Downloads a file from an url.
/// Returns `ok(file)` if the downloading succeeded.
/// Designed to be easy to use with threads.
fn download__url_file(url: str, file: str) -> res[str] { ... }
/// Saves a string to a file.
/// Returns `ok(file)` if the saving succeeded.
/// Designed to be easy to use with threads.
fn save__string_file(string: str, file: str) -> res[str] { ... }
/// Loads a string from file.
/// Returns `ok(text)` if the loading succeeded.
fn load_string__file(file: str) -> res[str] { ... }
/// Loads a string from url.
/// Returns `ok(text)` if the loading succeeded.
fn load_string__url(url: str) -> res[str] { ... }
/// Waits for thread to finish and returns the result.
fn join__thread(t: thr[any]) -> res[any] { ... }
/// Loads Dyon data from file.
/// Returns `ok(data)` if loading succeeded.
fn load_data__file(file: str) -> res[any] { ... }
/// Saves Dyon data to file, replacing any existing file.
/// Returns `ok(file)` if saving succeeded.
/// Designed to be easy to use with threads.
fn save__data_file(data: any, file: str) -> res[str] { ... }
/// Loads Dyon data from string.
fn load_data__string(string: str) -> res[any] { ... }
/// Returns the arguments which this program was started with.
/// The first element is usually the path of the executable.
fn args_os() -> [str] { ... }
/// Generates JSON data from meta data.
fn json_from_meta_data(meta_data: [[any]]) -> str { ... }
/// Generates string for error message.
/// Uses same format as [Piston-Meta](https://github.com/PistonDevelopers/meta).
/// The range is in characters by `start` and `len`.
fn errstr__string_start_len_msg(text: str, start: f64, len: f64, msg: str) -> str { ... }
/// Returns `true` if object has key.
fn has(obj: {}, key: str) -> bool { ... }
/// Returns all keys of an object.
fn keys(obj: {}) -> [str] { ... }
/// Returns characters of a string.
fn chars(text: str) -> [str] { ... }
/// Returns seconds since last Unix Epoch.
/// Returns a negative number if system clock is adjusted before Unix Epoch.
fn now() -> f64 { ... }
/// Returns `true` if number is NaN.
fn is_nan(v: f64) -> bool { ... }
/// Blocks thread until message is received from channel.
fn wait_next(channel: in) -> opt[any] { ... }
/// Checks for message on channel.
fn next(channel: in) -> opt[any] { ... }