pub trait Express<T> where
    T: Clone
{ type OperatorFactory: MakeOperators<T>; type LiteralMatcher: MatchLiteral; fn eval(&self, vars: &[T]) -> ExResult<T>; fn eval_relaxed(&self, vars: &[T]) -> ExResult<T>; fn unparse(&self) -> &str; fn var_names(&self) -> &[String]; }
Expand description

Expressions implementing this trait can be parsed from stings, evaluated for specific variable values, and unparsed, i.e., transformed into a string representation.

Required Associated Types

Required Methods

Evaluates an expression with the given variable values and returns the computed result.

Arguments
  • vars - Values of the variables of the expression; the n-th value corresponds to the n-th variable in alphabetical order. Thereby, only the first occurrence of the variable in the string is relevant. If an expression has been created by partial derivation, the variables always coincide with those of the antiderivatives even in cases where variables are irrelevant such as (x)'=1.
Errors

If the number of variables in the parsed expression are different from the length of the variable slice, we return an ExError.

Evaluates an expression with the given variable values and returns the computed result. If more variables are passed than necessary the unnecessary ones are ignored.

Arguments
  • vars - Values of the variables of the expression; the n-th value corresponds to the n-th variable in alphabetical order. Thereby, only the first occurrence of the variable in the string is relevant. If an expression has been created by partial derivation, the variables always coincide with those of the antiderivatives even in cases where variables are irrelevant such as (x)'=1.
Errors

If the number of variables in the parsed expression is larger than the length of the variable slice, we return an ExError.

Creates an expression string that corresponds to the FlatEx instance.

use exmex::prelude::*;
let flatex = FlatEx::<f64>::from_str("--sin ( z) +  {another var} + 1 + 2")?;
assert_eq!(format!("{}", flatex), "--sin ( z) +  {another var} + 1 + 2");

Returns the variables of the expression

Implementors