Skip to content
/ mm Public

Simple CLI math expression evaluator

License

Notifications You must be signed in to change notification settings

mymmrac/mm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💠 mm

Simple CLI math expression evaluator.

mm uses repl to interact with user with live results and error highlighting, but immediate mode is also supported.

🧩 Get Started

Install using go install:

go install github.com/mymmrac/mm@latest

Note: Make sure to add $GOPATH/bin into $PATH

Start repl and type some expressions:

mm

> 1 + 1

> 2 ^ 8 / 3.1

> 1 / ceil(2.5 + 4 / (abs(sin(5))))

⌨️ Shortcuts

  • Enter - evaluate expression
  • Up, Tab - previews executed expression
  • Down, Shift+Tab - next executed expression
  • Shift+Tab - use the result of last expression as input (only if input empty)
  • Esc - exit if input is empty, or clean input
  • Crtl+c - force quit

⚡ Operators

Binary

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • // Floor division
  • ^ Power
  • % Modulo

Unary

  • + Plus
  • - Minus

#️⃣ Functions

  • sqrt/1 Square root
  • abs/1 Absolute value
  • round/1 Round to integer
  • round/2 Round with precision
  • roundUp/1 Round up to integer
  • roundUp/2 Round up with precision
  • floor/1 Floor
  • ceil/1 Ceil
  • sin/1 Sine
  • cos/1 Cosine
  • tan/1 Tangent
  • atan/1 Arc tangent
  • rad/1 To radians
  • min/2 Minimum
  • max/2 Maximum
  • rand/0 Random value [0, 1)

Note: <name>/N means that <name> is called with N arguments

📖 Constants

  • Pi - 3.1415926...
  • e - 2.7182818...

🔐 License

mm is distributed under MIT licence.