Module arithmetic_eval::fns
source · Expand description
Standard functions for the interpreter, and the tools to define new native functions.
§Defining native functions
There are several ways to define new native functions:
Structs§
- Function that checks whether all of array items satisfy the provided predicate.
- Function that checks whether any of array items satisfy the provided predicate.
- Function generating an array by mapping its indexes.
- Assertion function.
- Assertion that two values are close to each other.
- Equality assertion function.
- Assertion that the provided function raises an error. Errors can optionally be matched against a predicate.
- Acts similarly to the
dbg!
macro, outputting the argument(s) to stderr and returning them. If a single argument is provided, it’s returned as-is; otherwise, the arguments are wrapped into a tuple. - Allows to define a value recursively, by referencing a value being created.
- Filter function that evaluates the provided function on each item of the tuple and retains only elements for which the function returned
true
. - Wrapper of a function containing information about its arguments.
- Reduce (aka fold) function that reduces the provided tuple to a single value.
- Error raised when a value cannot be converted to the expected type when using
FnWrapper
. if
function that eagerly evaluates “if” / “else” terms.- Function returning array / object length.
- Map function that evaluates the provided function on each item of the tuple.
- Function that merges two tuples.
- Function that appends a value onto a tuple.
- Loop function that evaluates the provided closure while a certain condition is true. Returns the loop state afterwards.
Enums§
- Comparator functions on two primitive arguments. All functions use
Arithmetic
to determine ordering between the args. - Generic error output encompassing all error types supported by wrapped functions.
- Error kinds for
FromValueError
. - Element of the
FromValueError
location.
Traits§
- Converts type into
Value
or an error. This is used to convert the return type of wrapped functions to the result expected byNativeFn
. - Fallible conversion from
Value
to a function argument.
Functions§
- Wraps a function enriching it with the information about its arguments. This is a slightly shorter way to create wrappers compared to calling
FnWrapper::new()
.
Type Aliases§
- Binary function wrapper.
- Quaternary function wrapper.
- Ternary function wrapper.
- Unary function wrapper.