A calculator for common fractions

Improve validation of impure expressions

Give a name to the special reference value for '$$'

Use madeline instead of a custom line editor

- read-only
- https://git.sr.ht/~yerinalexey/csq
- read/write
- git@git.sr.ht:~yerinalexey/csq

csq -

calculatorsquared, or just calculatorĀ²

Fancy command-line calculator that uses fractions instead of decimal floating point numbers.

It works like any other calculator, with exception of division, which returns
a fraction. After evaluation, the result is reduced, so
`(4 + 3) / 21 = 7/21 = 1/3`

. Basic line editing is also provided. Press
`Ctrl+D`

to quit.

Syntax reference:

`a + b`

,`a - b`

,`a * b`

,`a / b`

- self-explanatory`a ^ b`

- raises*a*to the power of*b*,*b*must have denominator of 1`a % b`

- returns the remainder from divsion of*a*by*b*, both must have denominator of 1`(expression)`

- sets highest precedence for*expression*`$N`

- returns the value of*N*-th expression`$$`

- return the value of the previous expression`sqrt(a)`

- returns a very approximated square root of*a*`a!`

- returns a factorial of*a*. Note that it currently can't compute factorials larger than`20!`

.`option <name> [value]`

- set or get the value of an option`option mixed [0|1]`

- whether mixed fractions should be displayed. Default:**1**`option preview [0|1]`

- whether inline previews should be displayed Default:**1**

Example:

```
$ csq
(1) 21 / 7 = 3
(2) 7 / 21 = 1/3
(3) $2 * 3 = 1
(4) sqrt(64) = 8
(5) 0.5 ^ 2 = 1/4
```

Dependencies:

```
$ make
# make install
```

Please send patches to ~yerinalexey/public-inbox@lists.sr.ht using
git send-email with prefix set to `csq`

:

```
$ git config format.subjectPrefix "PATCH csq"
```