mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Add rounding functionalties (#2672)
* added math round * added math floor * added math ceil * added math.md examples * moved the detection of nonnumerical values in ceil/floor/round * math round now works on streams * math floor now works on streams * math ceil now works on streams
This commit is contained in:
@ -4,11 +4,14 @@ 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 ceil`: Applies the ceil function to a list of numbers
|
||||
* [`math eval`](math-eval.md): Evaluates a list of math expressions into numbers
|
||||
* `math floor`: Applies the floor function to a list of numbers
|
||||
* `math max`: Finds the maximum within a list of numbers or tables
|
||||
* `math median`: Finds the median of a list of numbers or tables
|
||||
* `math min`: Finds the minimum within a list of numbers or tables
|
||||
* `math mode`: Finds the most frequent element(s) within a list of numbers or tables
|
||||
* `math round`: Applies the round function to a list of numbers
|
||||
* `math stddev`: Finds the standard deviation of a list of numbers or tables
|
||||
* `math sum`: Finds the sum of a list of numbers or tables
|
||||
* `math product`: Finds the product of a list of numbers or tables
|
||||
@ -117,6 +120,33 @@ To get the average of the file sizes in a directory, simply pipe the size column
|
||||
328.96
|
||||
```
|
||||
|
||||
```shell
|
||||
> echo [1.5 2.3 -3.1] | math ceil
|
||||
───┬────
|
||||
0 │ 2
|
||||
1 │ 3
|
||||
2 │ -3
|
||||
───┴────
|
||||
```
|
||||
|
||||
```shell
|
||||
> echo [1.5 2.3 -3.1] | math floor
|
||||
───┬────
|
||||
0 │ 1
|
||||
1 │ 2
|
||||
2 │ -4
|
||||
───┴────
|
||||
```
|
||||
|
||||
```shell
|
||||
> echo [1.5 2.3 -3.1] | math round
|
||||
───┬────
|
||||
0 │ 2
|
||||
1 │ 2
|
||||
2 │ -3
|
||||
───┴────
|
||||
```
|
||||
|
||||
### Dates
|
||||
|
||||
```shell
|
||||
|
Reference in New Issue
Block a user