Enum mexprp::Term
[−]
[src]
pub enum Term<N: Num> { Num(Answer<N>), Operation(Rc<Operate<N>>), Function(String, Vec<Term<N>>), Var(String), }
The main representation of parsed equations. It is an operand that can contain an operation between more of itself. This form is the only one that can be directly evaluated. Does not include it's own context.
Variants
Num(Answer<N>)
A number
Operation(Rc<Operate<N>>)
An operation
Function(String, Vec<Term<N>>)
A function with the given arguments
Var(String)
A variable
Methods
impl<N: Num + 'static> Term<N>
[src]
pub fn parse(raw: &str) -> Result<Self, ParseError>
[src]
Parse a string into an expression
pub fn parse_ctx(raw: &str, ctx: &Context<N>) -> Result<Self, ParseError>
[src]
Parse a string into an expression with the given context
pub fn eval(&self) -> Calculation<N>
[src]
Evaluate the term with the default context
pub fn eval_ctx(&self, ctx: &Context<N>) -> Calculation<N>
[src]
Evaluate the term with the given context
pub fn to_string(&self) -> String
[src]
Express this term as a string
Trait Implementations
impl<N: Debug + Num> Debug for Term<N>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<N: Clone + Num> Clone for Term<N>
[src]
fn clone(&self) -> Term<N>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<N: Num + 'static> Display for Term<N>
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<N: Num> From<Expression<N>> for Term<N>
[src]
fn from(t: Expression<N>) -> Term<N>
[src]
Performs the conversion.