kalkulator 0.1.0

A mathematical expression evaluation tool and library
Documentation
kalkulator-0.1.0 has been yanked.

Kalkulator

kalkulator is a versatile tool for mathematical expression evaluation, offering both a command-line interface for direct usage and a library for integration into Rust projects.

Features

  • Evaluate mathematical expressions with support for basic arithmetic operations and factorials.
  • Convert expressions to postfix notation.
  • Extendable for future operations and functionalities.

Installation

As a Command-Line Tool

Ensure you have Rust and Cargo installed on your system. If you don't have Rust installed, you can install it from the official site.

You can install kalkulator directly from crates.io by running:

cargo install kalkulator

This command installs the kalkulator binary, making it available for use in your terminal

As a library

Add kalkulator as a dependency in your Cargo.toml to use it in your Rust project.

[dependencies]
kalkulator = "0.1.0"

Usage

To convert an expression to postfix notation without evaluating:

kalkulator --expr "2+3/4" -p

To evaluate the result of an expression:

kalkulator --expr "2+3/4"

Example

Command-Line Interface

Evaluate an expression with basic arithmetic operations:

Command:

    kalkulator --expr "3+4*2"

Output:

    Result = 11

Evaluate an Expression involving factorial

Command:

    kalkulator --expr "5!/(2+3)"

Output:

    Result = 24

Library

Here is a basic example of using kalkulator to evaluate an expression within a Rust project:

use kalkulator::Expression;

fn main() {
    let mut expr = Expression::new("3+4*2");
    expr.infix_to_postfix().unwrap();
    expr.compute_expression().unwrap();

    println!("The result is = {}", expr.get_result().unwrap());
}

For more detailed usage, check documentation.

Contributing

Contributions are welcome!