Rename calc to math eval and allow it to optionally take an expression as an argument (#2195)

* Rename `calc` to `math eval` and allow it to optionally take the expression as an argument

* Moved calc tests to math eval
Also added 2 tests and changed 1 test

* Move calc docs to math eval
This commit is contained in:
Shaurya Shubham
2020-07-18 09:41:19 +05:30
committed by GitHub
parent 04e8aa31fe
commit ffe3e2c16b
11 changed files with 207 additions and 170 deletions

View File

@ -4,6 +4,7 @@ Mathematical functions that generally only operate on a list of numbers (integer
Currently the following functions are implemented:
* `math avg`: Finds the average of a list of numbers or tables
* [`math eval`](math-eval.md): Evaluates a list of math expressions into numbers
* `math min`: Finds the minimum within a list of numbers or tables
* `math max`: Finds the maximum within a list of numbers or tables
* `math median`: Finds the median of a list of numbers or tables
@ -152,11 +153,3 @@ To get the sum of the characters that make up your present working directory.
> echo [] | math avg
error: Error: Unexpected: Cannot perform aggregate math operation on empty data
```
Note `math` functions only work on list of numbers (integers, decimals, bytes) and tables of numbers, if any other types are piped into the function
then unexpected results can occur.
```shell
> echo [1 2 a ] | math avg
0
```