Package-level declarations

Types

Link copied to clipboard

An expression could not be read or evaluated, see ExpressionProblems for where: the exception of the untyped evaluator, so that both are caught alike

Link copied to clipboard
typealias TypedFunction0 = () -> Any
Link copied to clipboard
typealias TypedFunction1 = (Any) -> Any
Link copied to clipboard
typealias TypedFunction2 = (Any, Any) -> Any
Link copied to clipboard
typealias TypedFunction3 = (Any, Any, Any) -> Any
Link copied to clipboard
typealias TypedFunction4 = (Any, Any, Any, Any) -> Any
Link copied to clipboard
typealias TypedFunction5 = (Any, Any, Any, Any, Any) -> Any
Link copied to clipboard
class TypedFunctionExtensions(val functions0: Map<String, TypedFunction0> = emptyMap(), val functions1: Map<String, TypedFunction1> = emptyMap(), val functions2: Map<String, TypedFunction2> = emptyMap(), val functions3: Map<String, TypedFunction3> = emptyMap(), val functions4: Map<String, TypedFunction4> = emptyMap(), val functions5: Map<String, TypedFunction5> = emptyMap(), val properties: (receiver: Any, name: String) -> Any? = { _, _ -> null })

Functions

Link copied to clipboard
fun abs(x: Any): Any
Link copied to clipboard
fun checkTypedExpression(expression: String, values: Set<String>, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): List<ExpressionProblem>

The problems of the typed expression, all of them, without evaluating it: syntax errors, names that are neither in values, parameters of the lambdas and functions around them, values declared before them nor PI, values and functions declared twice, functions of more than 5 parameters, calls of functions that are neither built in, in functions nor in values (a constant can be a function), or that take other numbers of arguments, and lambdas of more than two parameters. The types of values are not known before they are evaluated, so the properties and functions of values, and the types of operands, are not checked. Names are only checked when the expression can be read.

Link copied to clipboard
fun <T0, R> compileFunction1(expression: String, parameter0: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): (T0) -> R

Compiles a string expression into a single-parameter function capable of evaluating the expression.

Link copied to clipboard
fun <T0, R> compileFunction1OrNull(expression: String, parameter0: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY, onError: (Throwable) -> Unit = { }): (T0) -> R?

Tries to compile a given string expression into a single-parameter function. Returns the compiled function if successful, or null if an error occurs during compilation. Errors are handled using the provided onError callback.

Link copied to clipboard
fun <T0, T1, R> compileFunction2(expression: String, parameter0: String, parameter1: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): (T0, T1) -> R

Compiles a string expression into a lambda function with two parameters.

Link copied to clipboard
fun <T0, T1, R> compileFunction2OrNull(expression: String, parameter0: String, parameter1: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY, onError: (Throwable) -> Unit = { }): (T0, T1) -> R?

Attempts to compile a string expression into a lambda function with two parameters, returning null if an error occurs during compilation.

Link copied to clipboard
fun <T0, T1, T2, R> compileFunction3(expression: String, parameter0: String, parameter1: String, parameter2: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): (T0, T1, T2) -> R

Compiles a 3-parameter function from a given string expression, allowing dynamic evaluation with specified parameters, constants, and external function extensions.

Link copied to clipboard
fun <T0, T1, T2, R> compileFunction3OrNull(expression: String, parameter0: String, parameter1: String, parameter2: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY, onError: (Throwable) -> Unit = { }): (T0, T1, T2) -> R?

Compiles a 3-parameter function from a given string expression, returning null if an error occurs during compilation.

Link copied to clipboard
fun compileTypedExpression(expression: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): () -> Any

Compiles a typed expression and returns a lambda that can execute the compiled expression.

Link copied to clipboard
fun evaluateTypedExpression(expression: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): Any?

Evaluates a typed expression based on the provided string input, constants, and function definitions.

Link copied to clipboard

the names of the values that the typed expression reads, without the parameters of its lambdas and functions, the values it declares before reading them and PI, as far as it can be read