kalkulator

Crates.iokalkulator
lib.rskalkulator
version0.2.2
sourcesrc
created_at2024-03-01 10:45:07.686408
updated_at2024-04-18 14:28:13.522578
descriptionA mathematical expression evaluation tool and library
homepage
repositoryhttps://github.com/adityanav123/kalkulator
max_upload_size
id1158768
size26,317
Aditya Navphule (adityanav123)

documentation

README

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 arithmatic operations, factorial, logical operations
  • Convert expressions to postfix notation.
  • Extendable for future operations and functionalities.

Further Extensions

  • Support for Logarithmic and Trignometric Functions

  • Exponentiation (x^y)

  • Absolute Value, Rounding Functions

  • Complex Numbers Support

  • Computation history support

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.1"

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

To show all available operations:

kalkulator --show-ops

Library Usage

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

use kalkulator::Expression;

let mut expr = Expression::new("3+4*2");
expr.infix_to_postfix().unwrap(); // Converts to postfix notation
expr.compute_expression().unwrap(); // Evaluates the expression
assert_eq!(expr.get_result().unwrap(), 11); // The result is 11

Using the Expression struct to evaluate an expression with factorial and division:

use kalkulator::Expression;

let mut expr = Expression::new("4!/(2+3)");
expr.infix_to_postfix().unwrap(); // Converts to postfix notation
expr.compute_expression().unwrap(); // Evaluates the expression
assert_eq!(expr.get_result().unwrap(), 24); // The result is 24 (120 / 5)

For more detailed usage, check documentation: Docs

Contributing

Contributions are welcome!, Whether it's adding new features, improving existing ones, or reporting bugs, your input is valuable. Check out the project's repository on GitHub

Commit count: 13

cargo fmt