run
cargo build --release
- operator precedense
- operator associativity
- nesting
- functions
- function from operator
- pipes
- variables
for convenience target/release/math-expression-evaluator
will be called calc
all whitespace characters are ignored!
to evaluate expression run following
calc "expression"
to use variables specifie them in following format
calc --var <var_name>=<value> "expression"
example
calc --var a=1 --var b=2 "a+b-3"
parentheses are respected
calc "4*(2+3)"
outputs 20
as expected
functions can be used in different ways
classic call (trailing comma is optional)
calc "add(2,5,)"
converting operator to function
calc "(+)(2,5)"
every function is automatically curried
calc "(+)(2)(5)"
calc "add(2)(5)"
pipes syntax is
calc "<value> | <one_arg_function>"
example
calc "2|(+)(4)|(^)(3)"
and it's equal to
calc "3^(2+(4))"
this project was created to learn rust and parsers