nushell/crates/nu-command/src/math
Sigurd afb7e1cf66
Allow tables and records as input to math commands (#11496)
# Description
The math functions `avg`, `max`, `median`, `min`, `product`, `stddev`,
`sum` and `variance` all takes a list as input and return a number.
<https://github.com/nushell/nushell/blob/main/crates/nu-command/src/math/utils.rs>
contains code that makes these functions work for tables (by running the
function on each column), but this functionality has not been accessible
because the input types are too strict. This PR remedies this.

The functions should also work on records, since a record is basically a
one-row table.

Most of these functions also make sense for durations and file sizes,
except `product` of course. There's an implementation issue with
`stddev` and `variance` for durations and file sizes, but they could in
principle support it.

# User-Facing Changes
This PR only adds supported types, and doesn't remove any, so there
should be no breaking changes.
2024-01-17 06:39:50 -06:00
..
abs.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
avg.rs Allow tables and records as input to math commands (#11496) 2024-01-17 06:39:50 -06:00
ceil.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
floor.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
log.rs Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
math_.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
max.rs Allow tables and records as input to math commands (#11496) 2024-01-17 06:39:50 -06:00
median.rs Allow tables and records as input to math commands (#11496) 2024-01-17 06:39:50 -06:00
min.rs Allow tables and records as input to math commands (#11496) 2024-01-17 06:39:50 -06:00
mod.rs cratification: part III of the math commands to nu-cmd-extra (#9674) 2023-07-13 09:11:26 -07:00
mode.rs Convert ShellError::UnsupportedInput to named fields (#10971) 2023-11-07 23:25:32 +01:00
product.rs Allow tables and records as input to math commands (#11496) 2024-01-17 06:39:50 -06:00
reducers.rs Apply nightly clippy fixes (#11083) 2023-11-17 09:15:55 -06:00
round.rs Add long options for generators and math (#10752) 2023-10-19 18:17:42 +02:00
sqrt.rs Convert ShellError::UnsupportedInput to named fields (#10971) 2023-11-07 23:25:32 +01:00
stddev.rs Allow tables and records as input to math commands (#11496) 2024-01-17 06:39:50 -06:00
sum.rs Allow tables and records as input to math commands (#11496) 2024-01-17 06:39:50 -06:00
utils.rs Move more commands to opaque Record type (#11122) 2023-11-22 23:48:48 +01:00
variance.rs Allow tables and records as input to math commands (#11496) 2024-01-17 06:39:50 -06:00