Skip to content
Calc is a prototype of a calculator with basic algebraic simplification written in Go.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
aslice
eval
math2
operation
relay
shuntingyard
steps
tree
web
Gopkg.lock
Gopkg.toml
Procfile
README.md
heroku.yml
main.go
screenshot.png

README.md

Calc

Calc is a prototype of a calculator with basic algebraic simplification written in Go.

Screenshot

Calc Screenshot

Features

  • Basic algebraic simplification (e.g. x+x = 2*x)
  • Base conversion (binary, octal and hexadecimal to decimal)
  • Web interface for input and output (based on bootstrap)

Usage

  • go get github.com/sj14/calc
  • cd $GOPATH/src/github.com/sj14/calc
  • go run main.go
  • open a web browser and enter http://localhost:9000/

Basic architecture

  1. Decide (regex) the input type (base conversion or mathematical term) (relay)

Base Conversion

  1. Do base conversion (relay)
  2. Show result

Algebraic simplification

  1. Convert the input term into an Abstract Syntax Tree (shuntingyard)
  2. Evaluate the AST (eval)
  3. Show the result

Problems / Limitations / TODO

  • The traversing order of the AST is from right to left instead left to right
  • No unary operations (e.g. -5 will result into 0-5)
  • Usage of float64 instead of math/big
  • Make usage of steps.go
  • ...
You can’t perform that action at this time.