A toy CLI calculator in Clojure.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/calc
test/calc
.travis.yml
README.md
project.clj

README.md

calc

A toy CLI calculator in Clojure.

Requirements

Example Usage

lein run

Calculator 1.0
Please enter an arithmetic expression separated by spaces.
i.e. 1 + 2 / 3 * 4
Type bye, quit, exit or Ctrl-D to exit.
Enter an expression:
1 + 2
=>  3
Enter an expression:
2 * 3 + 4
=>  10
Enter an expression:
10 + 2 * 100 / ((40 - 37) * 100 * (2 - 4 + 8 * 16))
=>  1891/189
Enter an expression:
Bye!

You can also run from the command line as follows:

$ lein uberjar
$ java -cp target/calc-0.1-SNAPSHOT-standalone.jar calc.main

Motivation and Goals

The core functionality of the calc app itself is not that interesting. The primary goal of this project is to provide a platform for learning the Clojure development cycle, test frameworks, trying new tools, etc. - without getting too bogged down in the details of the actual application.

If you are looking for an infix library to use in your Clojure application, here are two:

Acknowledgements

I started this project to answer the following StackOverflow problem: How to write the shortest and most idiomatic CLI calculator in Clojure

I used Eric Robert's Programming Abstractions in C (Addison Wesley, 1997) as a reference in coding my implementation. Chapter 14 "Expression Trees" describes an almost identical problem.

Continuous Integration

Build Status

CI is hosted by travis-ci.org

License

Creative Commons CC0 1.0 Universal

See: http://creativecommons.org/publicdomain/zero/1.0/legalcode

Noah Zucker (nzucker at gmail.com / @noahlz)