Calc: A fully-featured minimalistic configurable calculator written in Rust

Related tags

Command-line calc
Overview

Calc

Calc: A fully-featured minimalistic configurable rust calculator

Rust Test Release

Install

You can install the latest version from source

git clone https://github.com/coco33920/calc
cd calc 
cargo build --release
./target/release/mini-calc

or install it via cargo

cargo install mini-calc

Explaining

Check the website for more informations.

TODO List

  • Lexing of basic operations
    • Lexing operators
    • Lexing lpar,rpar,quote
    • Lexing int
    • Lexing floats
    • Lexing identifiers
  • Parsing of basic operations
    • Parsing int,floats,identifiers
    • sum operation
    • minus operation
    • multiplication operation
    • division operation
  • Parsing advanced operations
    • Parsing lpar,rpar
    • mathematical priority
      • Left priority
      • Right priority
    • parenthesis support
    • Assignment
    • associativity support
      • Left associativity
      • Right associativity
  • Application REPL
    • Add the REPL
      • basic REPL
      • colour message
      • colourised prompt
    • Add colour
  • Interpreter
    • Basic operation interpreter
    • Advanced operation interpreter
    • Identifiers (variable) interpreter
  • Built-in
    • pi
    • e
  • Config
    • Config colours
    • Config prompt
    • Config floating point accuracy
  • Add more operations
    • exponent
  • Add support for functions
    • exp
    • ln
    • log base a
    • cos/sin/tan
    • cosh/sinh/tanh
    • atan/acos/asin
  • Add logic
    • Add basic true/false
    • Add binary operator
      • or (&&)
      • and (||)
      • >=
      • >
      • <=
      • <
      • ==
    • Add unary operator
      • not (!)
  • Vector calculation
    • Add vectors to the datatypes
    • Lex vectors
    • Parse vectors
    • Add vector operations
      • Dot product
      • Vector norm
      • Vector addition
  • Matrix calculation
    • Add matrix to the datatypes
    • Lex matrices
    • Parse matrices
    • Add matrices operation
      • Matrix addition
      • Matrix multiplication
      • Calculate the matrix determinant
      • Calculate the reverse matrix
  • Interact with the configuration
    • Print current config
    • Reset config to default
    •  Set config
      • Set main color
      • Set prompt color
      •  Set prompt
      • Set greeting message
      •  Set greeting color
    •  Reload config

Evolution

Ploting

Plot functions (both stdlib, and runtime) would be useful and appreciated.

  • Plot stdlib functions
  •  Plot runtime functions
  • Save plot to png/svg/pdf

Exact math calculator

As this project provides a frontend with a parser we could plug an exact math engine in the backend to transform calc into a real exact math calculator. TODO List for the Exact Math Engine

  • Rational calculation
    • Implement rational numbers operations
    • Rational reduction
  • Irrational calculation
    • Implement irrational numbers operations
    • Irrational reduction
  • Literal calculation
    • Computes literal expression with uninitialized operators
    • Literal reduction

CAS

If we ever go to this step, yes, I will remove the "minimalistic" from the description

  • It's hard.

Examples

REPL with only Lexing (verbose mode: on by default)

REPL with lexing and basic operation parsing (verbose mode: on by default)

REPL and functionning interpreter (verbose mode: off by default)

Configuration

You can configure the general color, greeting message, greeting color, prompt and prompt color from the file for example in (for linux)

~/.config/mini-calc/mini-calc.toml

Or situated in your operating system config folder.

What the configuration looks like

The default configuration looks like this

img.png

Colors

Available colors are

  • purple
  • cyan
  • blue
  • black
  • red
  • yellow
  • green
  • white
  • an hexadecimal colour (ex: "#f7a8d8")

Default colour (if the configuration fail to load) is Cyan.

Example of a modified configuration

Configuration:

img.png

It looks like:

img.png

Functions

The following functions are available

  • sin
  • cos
  • tan
  • sinh
  • cosh
  • tanh
  • asin
  • acos
  • atan
  • exp
  • ln (alias: log)
  • sqrt
  • factorial (alias: fact)
  • abs
  • ceil
  • floor
  • round

Trigonometry

For trigonometry, the input are assumed to be in radian, if not, you have to put "false" or "true" as second argument, example shown bellow

img.png

Exp/ln

If you use the exp function you can pass a second argument for the base you are using, if no second arguments are passed this is assumed to be in natural base

img.png

Root

You can take the nth root with the sqrt function, by default it takes the second root.

img.png

Round

You can round to the nth decimal with the round function, by default it round to the integer (floor)

img.png

Logic

You can now use logic! I implemented the following functions:

  • or (alias : ||)
  • and (alias : &&)
  • geq (alias : >=)
  • gt (alias : >)
  • leq (alias : <=)
  • lt (alias :<)
  • eq (alias : ==)

Example:

img.png

User defined functions!

You can define your own functions!

img.png

Vector calculation !

You can use vectors!

  • add vector to each others
  • added the norm function to compute the norm
  • dot product between two vectors ( * operator)

Functions added:

  • norm

Matrices !

As of 2.7.0 matrix algebra is implemented (using lup reduction)

  • you can add matrices
  • multiply compatible matrices

functions added

  • transpose
  • invert
  • det

Comments
  • feat: add matrices support

    feat: add matrices support

    • [x] Matrix calculation
      • [X] Add matrix to the datatypes
      • [X] Lex matrices
      • [X] Parse matrices
      • [x] Add matrices operation
        • [X] Matrix addition
        • [X] Matrix transpose
        • [x] Matrix multiplication
        • [x] Calculate the reverse matrix
    enhancement 
    opened by coco33920 0
  • Add vectors

    Add vectors

    • [X] Vector calculation
      • [X] Add vectors to the datatypes
      • [X] Lex vectors
      • [X] Parse vectors
      • [X] Add vector operations
        • [X] Dot product
        • [X] Vector norm
        • [X] Vector addition
    opened by coco33920 0
  • Add logic

    Add logic

    Add implementation of logic done:

    • [X] Add logic
      • [X] Add basic true/false
      • [X] Add binary operator
        • [X] or (&&)
        • [X] and (||)
        • [X] >=
        • [X] >
        • [X] <=
        • [X] <
        • [X] ==
      • [X] Add unary operator
        • [X] not (!)
    opened by coco33920 0
  • Rewrite parser

    Rewrite parser

    Rewrite the entire parser

    • [X] Parse single token
    • [x] Parse simple operations
    • [x] Parse harder operations with parenthesis
    • [x] Parse harder operations without parenthesis (precedence)
    enhancement 
    opened by coco33920 0
  • Parse basic operations

    Parse basic operations

    Parsing of basic operations

    • [X] Parsing of basic operations
      • [X] Parsing int,floats,identifiers
      • [X] sum operation
      • [X] minus operation
      • [X] multiplication operation
      • [X] division operation
    opened by coco33920 0
  • Change config

    Change config

    • [ ] Interact with the configuration
      • [X] Print current config
      • [X] Reset config to default
      • [ ] Set config
        • [ ] Set main color
        • [ ] Set prompt color
        • [ ] Set prompt
        • [ ] Set greeting message
        • [ ] Set greeting color
      • [X] Reload config
    enhancement 
    opened by coco33920 0
Releases(2.7.0)
Owner
Charlotte Thomas
French Student in Computer science at @univ-rennes1. OCaml amateur
Charlotte Thomas
A full featured, fast Command Line Argument Parser for Rust

clap Command Line Argument Parser for Rust It is a simple-to-use, efficient, and full-featured library for parsing command line arguments and subcomma

null 10.4k Jan 10, 2023
A full featured, fast Command Line Argument Parser for Rust

clap Command Line Argument Parser for Rust It is a simple-to-use, efficient, and full-featured library for parsing command line arguments and subcomma

Ed Page 0 Jun 16, 2022
A customizable MCTS planner with advanced featured tailored to multi-agent simulations and emergent narratives.

NPC engine Core:  Utils:  © 2020-2022 ETH Zurich and other contributors. See AUTHORS.txt for more details. A customizable Monte Carlo Tree Search (MCT

Game Technology Center, ETH Zurich 30 Jun 6, 2023
A minimalistic blog/portfolio starter written in Rust. No database, bloat or JS.

rlog Rlog is a minimalistic blog/portfolio starter project intended to be used for a personal blog. The project is built using only Rust, HTML and CSS

jan 7 Aug 24, 2024
Simple OpenAI CLI wrapper written in Rust, feat. configurable prompts and models

Quick Start git clone https://github.com/ryantinder/ask-rs cd ask cargo install --path . Example ask tell me about the Lockheed Martin SR71 >> The Loc

Ryan Tinder 3 Aug 9, 2023
An Intel HAXM powered, protected mode, 32 bit, hypervisor addition calculator, written in Rust.

HyperCalc An Intel HAXM powered, protected mode, 32 bit, hypervisor addition calculator, written in Rust. Purpose None ?? . Mostly just to learn Rust

Michael B. 2 Mar 29, 2022
A CLI calculator written in Rust that isn't blazingly fast.

Calcamabob A command line calculator Is written in Rust Is not blazing fast, and could be faster. Calcamabob can interpret operator precedence. For ex

Casey Kneale 4 Oct 24, 2022
Ember is a minimalistic Rust library for creating 2D graphics, games, and interactive visualizations with ease and simplicity.

Ember Ember is a simple and fun 2D rendering library for Rust, allowing you to quickly create graphics and interactive applications with ease. It uses

null 8 May 4, 2023
zigfi is an open-source stocks, commodities and cryptocurrencies price monitoring CLI app, written fully in Rust, where you can organize assets you're watching easily into watchlists for easy access on your terminal.

zigfi zigfi is an open-source stocks, commodities and cryptocurrencies price monitoring CLI app, written fully in Rust, where you can organize assets

Aldrin Zigmund Cortez Velasco 18 Oct 24, 2022
A cross platform minimalistic text user interface

titik Titik is a crossplatform TUI widget library with the goal of being able to interact intuitively on these widgets. It uses crossterm as the under

Jovansonlee Cesar 113 Dec 31, 2022
A simple calculator, Rust implemention.

Calc A simple calculator. Usage If the name of the binary is calculator, To calculate: $ calculator -c <EXPRESSION> # or $ calculator --calc <EXPRESSI

Umoho Qerty 2 Aug 7, 2022
osu!Skills calculator rewritten in rust.

osu!Skills rs osu!Skills calculator rewritten in rust. Usage osu_skills_rs [OPTION]... Skill Calculator Mandatory: --in=FILE: Path to .osu file to pa

null 2 Dec 18, 2022
A simple command-line calculator program writen with Rust.

Calculator.rs An simple command-line calculator program writen with Rust. Features Math functions support > sin(1) = 0.84147098 Variable support > a

BHznJNs 33 Apr 8, 2023
Configurable, extensible, interactive line reader

linefeed linefeed is a configurable, concurrent, extensible, interactive input reader for Unix terminals and Windows console. API Documentation linefe

Murarth 176 Jan 3, 2023
Monorepo for dprint—a pluggable and configurable code formatting platform

dprint Monorepo for dprint—a pluggable and configurable code formatting platform. This project is under active early development. I recommend you chec

null 1.7k Jan 8, 2023
Easy configurable tmux display-menu

tmux-easy-menu Easy configurable tmux display-menu Setup cargo build And run with ./target/debug/tmux-menu show --menu {path-to-your-config} Configu

null 18 Jan 23, 2023
Uses the cardano mini-protocols to receive every block and transaction, and save them to a configurable destination

cardano-slurp Connects to one or more cardano-node's, streams all available transactions, and saves them to disk (or to S3) in raw cbor format. Usage

Pi Lanningham 16 Jan 31, 2023
⚡️(cd with env) Is a configurable cd wrapper that lets you define your environment per directory.

⚡️cdwe (cd with env) A simple configurable cd wrapper that provides powerful utilities for customizing your envionment per directory. (For ZSH / BASH

teo 20 Aug 6, 2023
Configurable, smart and fast CSS/SCSS/Sass/Less formatter.

?? Malva Malva is a configurable, smart and fast CSS/SCSS/Sass/Less formatter. Why? Configurable Malva is configurable. It provides several configurat

Pig Fang 20 Oct 27, 2023