Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/demonstrandum/crepl
An intuitive calculator Read-Eval-Print-Loop.
https://github.com/demonstrandum/crepl
c calculator compiler interpreter math mathematics numerical parser repl
Last synced: about 2 hours ago
JSON representation
An intuitive calculator Read-Eval-Print-Loop.
- Host: GitHub
- URL: https://github.com/demonstrandum/crepl
- Owner: Demonstrandum
- License: gpl-3.0
- Created: 2020-06-25T11:54:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-08T17:18:04.000Z (almost 2 years ago)
- Last Synced: 2024-01-26T11:05:20.029Z (9 months ago)
- Topics: c, calculator, compiler, interpreter, math, mathematics, numerical, parser, repl
- Language: C
- Homepage:
- Size: 139 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CREPL
> **C**alculator **REPL**A command line calculator read-eval-print-loop,
with intuitive mathematical notation as syntax.## Install
You'll need `git` (if cloning), a C compiler (e.g. `gcc`),
the GNU readline library, and `make` (`build-essential` / `base-devel`).### Clone
Clone / Download this repositroy however you like, e.g.
```sh
git clone "https://github.com/Demonstrandum/crepl.git"
```Then change directory into it:
```sh
cd crepl
```### Build & Install
```sh
make # Builds and compiles the project.
sudo make install # Installs the program system wide.
```You may also compile with debug-printing by `DEFINES=-DDEBUG make` instead.
## Example
An example of a session:
```console
::> k = 9
#=> 9
::> f x = 2x - k
::> f 10
#=> 11
::> addTo x = y -> x + y
::> add3 = addTo 3
::> add3 10
#=> 13
::> sum = x -> y -> x + y
::> (sum 2) 3
#=> 5
::> sin 2pi - 1
#=> -1
::> (k-2)!
#=> 5040
```## TODO
- [ ] Temporary variables with `let ... in ...` and `... where ...` expressions.
- [ ] Computed physical units with through postfix operators.
- [ ] User defined units.
- [ ] A `ref(.)` function, for referencing/aliasing other variables.
- [ ] Throw errors on overflows until we implement bignums.
- [ ] Imaginary numbers (using `complex.h`).
- [ ] User defined functions.
- [x] Single argument.
- [ ] Tuple argument.
- [x] Anonymous functions.
- [ ] Pool constant and literal values in a preallocated structure, to save on reallocating constants by preventing them from being garbage collected.
- [x] Garbage collection.
- [x] Reference count function scopes.
- [x] Reference count data values.
- [ ] Numerical equation solver (polynomial, simultaneous, &c.).
- [ ] Add more functionality, notably for calculus.
- [ ] Symbol manipulation (?).
- [ ] Extend numbers to include “Big Numbers” (“Big Integers” and “Big Decimals”/Rationals), numbers a currently limited to ~80bit floats and pointer-sized (likely 64bit) integeres.