SSCal

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2022 License: BSD-3-Clause Imports: 1 Imported by: 0

README ΒΆ

SSCal

SSCal (Stephen's Stack Calculator) is a stack-based postfix terminal calculator, written in pure Go 1.19 by Stephen Malone. It's a fast, reliable, open-source calculator for people who think in postfix.

Installation

Install SSCal with go install...

go install github.com/wirehaiku/SSCal@latest

... or download the latest binary release for your platform.

Usage

Run SSCal to open an interactive session with an empty stack. The stack is printed at the end of each line (if it's not empty).

$ SSCal
> 1 2 3 + +
[ 6 ]

All numbers in SSCal are floating-point, but numbers without decimal portions are presented as integers. Operators are a mix of letters and other symbols, and require a minimum number of arguments.

> 1 2.0 3.456
[ 1 2 3.456 ]

> sum
[ 5.456 ]

> sum
Error: not enough arguments.
Command-Line Options
Flag Description
-q Quiet mode, don't print opening banner.
-c STRING Print the result of STRING and quit.

Operators

All operators have a minimum number of arguments, shown in parentheses next to the operator's symbol. If the minimum has the suffix F, it indicates a folding operator that applies itself to all numbers on the stack.

Basic Math
Operator Description Example
+ (2) Add two numbers. 2 3 + πŸ‘’ [ 5 ]
- (2) Subtract two numbers. 2 3 - πŸ‘’ [ 1 ]
* (2) Multiply two numbers. 2 3 * πŸ‘’ [ 6 ]
/ (2) Divide two numbers. 2 6 / πŸ‘’ [ 3 ]
% (2) Modulo two numbers. 4 6 % πŸ‘’ [ 2 ]
^ (2) Exponent two numbers. 2 3 ^ πŸ‘’ [ 9 ]
Advanced Math
Operator Description Example
ceil (1) Get a number's ceiling. 1.23 ceil πŸ‘’ [ 2 ]
floor (1) Get a number's floor. 1.23 floor πŸ‘’ [ 1 ]
sqrt (1) Get a number's square. 9 sqrt πŸ‘’ [ 3 ]
min (2) Get the smaller number. 2 3 min πŸ‘’ [ 2 ]
max (2) Get the larger number. 2 3 max πŸ‘’ [ 3 ]
Folding Math
Operator Description Example
sum (2F) Add all numbers. 1 2 3 sum πŸ‘’ [ 6 ]
Stack Operators
Operator Description Example
dupe (1) Duplicate the top number. 1 2 dupe πŸ‘’ [ 1 2 2 ]
roll (1) Move the top number to the bottom. 1 2 3 roll πŸ‘’ [ 3 1 2 ]
swap (2) Swap the top two numbers. 1 2 swap πŸ‘’ [ 2 1 ]
wipe (0) Delete all numbers. 1 2 wipe πŸ‘’ [ ]

Contributions

Please submit all bugs and feature requests to the issue tracker, thank you.

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL