Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sykoram/clj-calculator
Just a calculator in Clojure
https://github.com/sykoram/clj-calculator
calculator clojure expression-evaluator functional-programming
Last synced: 4 days ago
JSON representation
Just a calculator in Clojure
- Host: GitHub
- URL: https://github.com/sykoram/clj-calculator
- Owner: sykoram
- License: other
- Created: 2021-06-14T15:55:40.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-14T18:28:01.000Z (over 3 years ago)
- Last Synced: 2024-12-15T21:20:56.975Z (about 2 months ago)
- Topics: calculator, clojure, expression-evaluator, functional-programming
- Language: Clojure
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# calculator
A calculator with a support for functions (and fractions - thanks to Clojure).
## Setup
[Clojure](https://clojure.org/) and [Leiningen](https://leiningen.org/) have to be installed and configured.
Run tests:
```
lein test
```Run the calculator:
```
lein run
```Run as a standalone JAR:
```
lein uberjar
java -jar target/uberjar/calculator-_VERSION_-standalone.jar
```## Usage
When you run the calculator, you may type in an mathematical expression you want to evaluate, eg. `((8.0 - log(2, 16))^3! + 2*52) /100`, or a command.
### Available commands
- `help`, `h` or `?`: Show help
- `exit`, `quit` or `q`: Exit the calculator### Supported features
#### operators
- `+`
- `-` (both subtraction and unary negation)
- `*`
- `/`
- `^` (power)
- `!` (factorial)#### functions
- *n*th root
- `sqrt(x)`
- `cbrt(x)`
- logarithms
- `log(base, x)`
- `ln(x)`
- `log10(x)`
- `log2(x)` or `lb(x)`
- goniometric
- `sin(x)`
- `cos(x)`
- `tan(x)` or `tg(x)`
- `cot(x)` or `cotg(x)`
- rounding
- `round(x)`
- `floor(x)`
- `ceil(x)`
- other
- `abs(x)`
- `sgn(x)` ([signum function](https://en.wikipedia.org/wiki/Sign_function))
- `double(x)`#### contants
- `pi`
- `e`
- `phi` or `golden_ratio`#### special characters
- parentheses: `(...)` or `[...]`
- separator (between function arguments): `,` or `;`