Skip to content

A simple library for mathematical expressions evaluation

License

Notifications You must be signed in to change notification settings

gamma-omg/simplecalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleCalc

A simple and efficient mathematical expression interpreter in Rust.

Features

Operators Supported:

  • Addition (+)
  • Subtraction (-)
  • Multiplication (*)
  • Division (/)
  • Exponentiation (**)

Usage

Here's a basic example of how to use SimpleCalc:

fn main() {
    match simplecalc::eval("1+2-3*4/5**6") {
        Ok(res) => println!("{res}"),
        Err(e) => println!("{e}"),
    }
}

Evaluate an expression:

let result = simplecalc::eval("10 + 5 * 2")?;
println!("{}", result); // Outputs: 20

Handle invalid expressions:

println!("{}", simplecalc::eval("invalud expression").err().unwrap());

About

A simple library for mathematical expressions evaluation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages