A simple command line based RPN calculator

Related tags

Command-line stak
Overview

stak

A simple command line based RPN calculator

Usage

stak can be used in two modes: one-shot from the command line, or in an interactive shell

One-shot

In one-shot mode, include the sequence of values and operators you wish to evaluate as arguments to the binary. Note that it may be required to put the arguments in quote marks depending on your shell.

$ stak 3 7 * 4 /
[5.25]
$ stak 12.6 17 / .5 3 ^
[0.7411764705882353, 0.125]

Interactive

To start stak in interactive mode, simply run the program with no arguments. Values and operators can be entered one at a time or on one line with spaces separating them. Type help or ? for a list of operators.

$ stak
> 3
[3.0]
> 4
[3.0, 4.0]
> 13.7 * 1.3 /
[3.0, 42.15384615384615]
> *
[126.46153846153845]

Mathematical Operators

The following operations are currently supported

Operation Symbol
Addition +
Subtraction -
Multiplication *
Division /
Modulus %
Power **
Parallel sum ||
Inversion inv
Square root sqrt
Log2 log2
Floor floor
Ceiling ceil
Absolute value abs
Summation of all values in the stack sum
Product of all vales in the stack prod

Stack Operators

The following operations can be performed on the stack

Clear ..

Clears the stack

Example:

$ stak
> 3 4 5 6
[3.0, 4.0, 5.0, 6.0]
> ..
[]

Pop .

Removes the top value from the stack

Example:

$ stak
> 3 4 5 6
[3.0, 4.0, 5.0, 6.0]
> .
[3.0, 4.0, 5.0]

Swap <>

Swaps the top two values of the stack

Example:

$ stak
> 3 4 5 6
[3.0, 4.0, 5.0, 6.0]
> <>
[3.0, 4.0, 6.0, 5.0]

Duplicate ~

Duplicates the top value of the stack. An optional index can be specified, duplicating the value at that index. Stack indices are zero-based and originate at the top of the stack.

Example:

$ stak
> 3 4 5 6
[3.0, 4.0, 5.0, 6.0]
> ~
[3.0, 4.0, 5.0, 6.0, 6.0]
> ~3
[3.0, 4.0, 5.0, 6.0, 6.0, 4.0]

Rotate Left <<

Rotates the stack to the left. An optional number of rotations can be specified

Example:

$ stak
> 3 4 5 6 7
[3.0, 4.0, 5.0, 6.0, 7.0]
> <<
[4.0, 5.0, 6.0, 7.0, 3.0]
> <<2
[6.0, 7.0, 3.0, 4.0, 5.0]

Rotate Right >>

Rotates the stack to the right. An optional number of rotations can be specified

Example:

$ stak
> 3 4 5 6 7
[3.0, 4.0, 5.0, 6.0, 7.0]
> >>
[7.0, 3.0, 4.0, 5.0, 6.0]
> >>2
[5.0, 6.0, 7.0, 3.0, 4.0]

Constants

The following mathematical constants are currently supported

  • pi
  • e

Example:

$ stak
> 2.5 2 ^ pi *
[19.634954084936208]
You might also like...
Pink is a command-line tool inspired by the Unix man command.

Pink is a command-line tool inspired by the Unix man command. It displays custom-formatted text pages in the terminal using a subset of HTML-like tags.

CLI calculator app and library

calc Yet another CLI calculator. Inspired by the excellent https://github.com/alfredxing/calc. Installation With a Rust toolchain in place: cargo inst

a (soon to be) calculator frontend and a (soon to be optimizing) toy IR backend

Zach-Calc Zach-Calc is a pet project for me to try and better understand pattern matching, optimization, IRs, and the likes. ./libs/* contains librari

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

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

A calculator working with text.
A calculator working with text.

Calculator A calculator working purely with text inputs. Downloading Desktop Version (Windows + Mac) available in the Releases Tab Web Version availab

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

A complex numbers, graphing, cli calculator

calc requires gnuplot for graphing history file is stored in ~/.config/.calc_history or C:\\Users\\%USERNAME%\\AppData\\Roaming\\calc.history usage Us

TI-89-style calculator, maybe turing complete
TI-89-style calculator, maybe turing complete

I will make a fully capable graphing calculator in Rust and you can't stop me. As always, I'm not using libraries or any of that. Everything here is h

Owner
null
JiaShiwen 12 Nov 5, 2022
Cork is a simple command-line calculator, mainly targeted towards people who deal with hex numbers

Cork is a simple command-line calculator, mainly targeted towards people who deal with hex numbers. It deals only with integer arithmetic. Expressions may involve mixed bases (limited to decimal, hexadecimal, octal and binary numbers). The global output format may be set to a particular radix - by default it is hex.

Deep Majumder 50 Dec 22, 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
Command Line Scientific Calculator. Free Forever. Made with ❤ī¸ using đŸĻ€

██████╗███████╗ ██████╗ ██╔════╝██╔════╝██╔════╝ ██║ ███████╗██║ ██║ ╚════██║██║ ╚██████╗███████║╚██████╗ ╚═════╝╚══════╝ ╚═════╝ -

zahash 17 Oct 28, 2023
Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

William D. Jones 5 Aug 20, 2022
An interactive Bayesian Probability Calculator CLI that guides users through updating beliefs based on new evidence.

Bayesian Probability Calculator CLI Welcome to the Bayesian Probability Calculator CLI! This command-line tool is designed to help you update your bel

Ben Greenberg 4 Apr 25, 2023
The PC-based component of a two-part Linux driver for using a TI calculator as an external keyboard

Introduction i68apollo is the computer-based component of the two-part i68 (*I*nput from Motorola *68*000[fn:4]-based calculator) prototype userspace

Joseph Burke 4 Aug 17, 2024
Simple calculator REPL, similar to bc(1), with syntax highlighting and persistent history

eva simple calculator REPL, similar to bc(1), with syntax highlighting and persistent history installation Homebrew $ brew install eva crates.io $ car

Akshay 632 Jan 4, 2023
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
Command-line HTTP client for sending a POST request to specified URI on each stdin line.

line2httppost Simple tool to read lines from stdin and post each line as separate POST request to a specified URL (TCP connection is reused though). G

Vitaly Shukela 3 Jan 3, 2023