A very simple calculator
  • Go 72.5%
  • Nix 27.5%
Find a file
2025-08-09 11:24:24 +02:00
.envrc initial commit 2025-08-01 15:03:40 +02:00
.gitignore add gitignore 2025-08-01 15:04:25 +02:00
flake.lock initial commit 2025-08-01 15:03:40 +02:00
flake.nix finalize the core program 2025-08-03 17:09:20 +02:00
go.mod stuff 2025-08-03 14:07:05 +02:00
main.go support ** as ^ 2025-08-09 10:38:15 +02:00
operations.go fix typo in abs application x.x 2025-08-09 02:49:42 +02:00
README.md add a README 2025-08-09 11:24:24 +02:00
tree.go finalize the core program 2025-08-03 17:09:20 +02:00

Putah - Just a Calculator

Might as well add a Readme.

When called, concatenates all arguments and tries to evaluate them with some basic math. Made it to be used in my Quickshell Widgets.

Behaviour:

  • Support for basic Operators, some 1 Argument Functions and Constants.
  • The functions behave like their golang math equivalents.
  • Support for Parentheses.
  • Parentheses around function arguments are optional (so sqrt 4 is valid and evaluates to 2).
  • When an Operator is omitted between 2 distinguishable expressions, Multiplication is assumed (4(2-3) = -4).
  • Uses Floating point math with no special handling so expect some inaccuracies (sin(pi) != 0)
  • All Text is Case-insensitive.
  • Returns NaN when there is a Syntax Error.
  • In theory Operators, Functions and Constants are pretty extensible in operations.go, but I cant think of any more to add.

Supported Operators

-, +, */x, /, %, ^/**

Supported Functions

log/log10, ln/loge, lb/log2, sqrt, sin, asin, cos, acos, tan, atan, abs, -

Supported Constants

pi, e, phi