From 99e5658feb48f15f85eaf9680affea2f490459bb Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 3 Jun 2020 12:02:31 +0200 Subject: Refactoring parsing, Fixing builtin, rewrite everything else --- README.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index eb7f2b7..512d881 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,62 @@ # computorv2 -computorv2 project of school 42 +Calculator REPL + +## Types + +| Name | Letter | Example | +|----------|--------|----------------------| +| Rational | Q | `1.5` | +| Complex | C | `1.5i + 1.5` | +| Matrix | M | `[ [1, 2]; [3, 4] ]` | + +Imaginary number are converted to Complex. + +## Operations + +* `+` Addition +* `-` Substraction +* `*` Multiplication +* `/` Division +* `%` Modulo +* `^` Exponent +* `**` Matrix multiplication + +| | Q | C | M | +|---|------------------------------|-------------------------|---------------------| +| Q | `+`, `-`, `*`, `/`, `^`, `%` | `+`, `-`, `*`, `/`, `^` | `*` | +| C | | `+`, `-`, `*`, `/`, `^` | `*` | +| M | | | `**`, `+`, `-`, `*` | + +## Expressions + +* Declaration + * Variable + * Function (with one parameter) +* Evaluation + +### Examples + +``` +> a = 1 + 3 +4 +> f(x) = x * 2 +x * 2 +> a = ? +4 +> f(4) = ? +16 +> f(4) + a + 5 = ? +25 +``` + +Uses eager evaluation, variable value is known after assignment, function value is reduced to the maximum (except for parameter). + +``` +> a = 3 +3 +> b = a + 3 +6 +> f(x) = 2 * 3 * 4 * x +24 * x +``` -- cgit