nushell/crates/nu-command/src
Loïc Riegel 2ea2a904e8
Math commands can work with bounded ranges and produce list of numbers (#15319)
No associated issue, but follows up #15135. See also discussion on
[discord](https://discord.com/channels/601130461678272522/1349139634281513093/1349139639356624966)
with @sholderbach

# Description

### Math commands `range -> list<number>`

This enables the following math commands:
- abs
- ceil
- floor
- log
- round

to work with ranges. When a range is given, the command will apply the
command on each item of the range, thus producing a list of number as
output.

Example

![image](https://github.com/user-attachments/assets/cff12724-5b26-4dbb-a979-a91c1b5652fc)

The commands still do not work work with unbounded ranges:


![image](https://github.com/user-attachments/assets/40c766a8-763f-461d-971b-2d58d11fc3a6)

And I left out the "mode" command because I think it does not make sense
to use it on ranges...

### Math commands `range -> number`

This was the topic of my previous PR, but for whatever reason I didn't
do `math variance` and `math stddev`.
I had to use `input.try_expand_range` to convert the range into a list
before computing the variance/stddev.


![image](https://github.com/user-attachments/assets/803954e7-1c2a-4c86-8b16-e16518131138)

And same, does not work in infinite ranges:


![image](https://github.com/user-attachments/assets/8bfaae2b-34cc-453d-8764-e42c815d28d3)

### Also done:
- find link in documentation

# User-Facing Changes
- Command signatures changes
- ability to use some commands with unbounded ranges
- ability to use variance and stddev with bounded ranges

# Tests + Formatting
Cargo fmt and clippy OK
Tests OK

# After Submitting
I guess nothing, or maybe release notes?
2025-03-20 17:35:50 +01:00
..
bytes fix range bugs in str substring, str index-of, slice, bytes at (#14863) 2025-01-30 06:50:01 -06:00
charting Add Filesize type (#14369) 2024-11-29 21:24:17 +00:00
conversions into string should not modify strings (#15320) 2025-03-16 20:11:05 +00:00
database Refactor I/O Errors (#14927) 2025-01-28 16:03:31 -06:00
date refactor: rename subcommand structs (#15309) 2025-03-14 02:00:35 +01:00
debug update sysinfo to 0.33.1 (#14982) 2025-02-03 06:33:23 -06:00
env Parse XML documents with DTDs by default, and add --disallow-dtd flag (#15272) 2025-03-12 08:09:55 -05:00
experimental Don't collect job output (#15365) 2025-03-20 09:49:12 -04:00
filesystem Remove nu-glob's dependency on nu-protocol (#15349) 2025-03-20 17:32:41 +01:00
filters Add default --empty to handle empty values (#15223) 2025-03-13 19:50:50 +01:00
formats Disallow DTD by default in from xml (#15325) 2025-03-17 14:16:17 +01:00
generators seq date: generalize to allow any duration for --increment argument (#14903) 2025-01-25 13:24:39 -06:00
hash add binary as input to hash commands (#13923) 2024-09-25 16:47:52 +08:00
help Rework operator type errors (#14429) 2025-02-12 20:03:40 -08:00
math Math commands can work with bounded ranges and produce list of numbers (#15319) 2025-03-20 17:35:50 +01:00
misc More precise ErrorKind::NotFound errors (#15149) 2025-02-22 11:42:44 -05:00
network Unify closure serializing logic for to nuon, to msgpack, and to json (#15285) 2025-03-16 20:15:02 +01:00
path refactor: rename subcommand structs (#15309) 2025-03-14 02:00:35 +01:00
platform refactor: rename subcommand structs (#15309) 2025-03-14 02:00:35 +01:00
random refactor: rename subcommand structs (#15309) 2025-03-14 02:00:35 +01:00
removed refactor: rename subcommand structs (#15309) 2025-03-14 02:00:35 +01:00
shells Jobs (#14883) 2025-02-25 12:09:52 -05:00
stor Run-time pipeline input typechecking tweaks (#14922) 2025-02-02 15:51:47 -05:00
strings refactor: rename subcommand structs (#15309) 2025-03-14 02:00:35 +01:00
system add more columns to macos ps -l (#15341) 2025-03-20 09:53:19 -05:00
viewers Refactor I/O Errors (#14927) 2025-01-28 16:03:31 -06:00
default_context.rs Feature-gate job unfreeze behind "os" (#15339) 2025-03-18 19:02:04 -04:00
example_test.rs Implementing ByteStream interuption on infinite stream (#13552) 2025-01-11 13:28:08 -08:00
lib.rs Start to Add WASM Support Again (#14418) 2024-11-30 07:57:11 -06:00
progress_bar.rs Cut down unnecessary lint allows (#14335) 2024-11-15 19:24:39 +01:00
sort_utils.rs Remove deprecated commands (#14726) 2025-01-07 07:37:51 +08:00