Basics
Related problem
The math functions recurse inconsistently into stacked data structures.
For example the "scalar input" functions math abs, math ceil, math floor recurses into lists inside records:
> {alice: -1.1, bob: [1,-2,3]} | math abs | to nuon
{alice: 1.1, bob [1, 2, 3]}
but not into records inside records:
> {alice: {clair: -1.1}, bob: [1,-2,3]} | math abs
Error: nu::shell::only_supports_this_input_type
× Input type not supported.
╭─[repl_entry #1:1:10]
1 │ {alice: {clair: -1.1}, bob: [1,-2,3]} | math abs
· ──────┬────── ────┬───
· │ ╰── only int, float, filesize, or duration input data is supported
· ╰── input type: record<clair: int>
╰────
This is inconsistent.
Similar
> { alice: {claire: [1 2]}, bob: [1.1, 2.1]} | math avg alice
ERROR
but
> { alice: ({claire: [1 2]} | math avg), bob: [1.1, 2.1]}
SUCCESS
which is contrary to what I as a user would expect how | math FUNC behaves.
Describe the solution you'd like
Make
{ alice: foo, bob: bar } | math FUNC
equivalent to
{ alice: (foo | math FUNC), bob (bar | math FUNC) }
(and similarily if a cell path is given), i.e. the application of | math FUNC recurses into the record structure. This would then allow
{ alice: {claire: [1 2]}, bob: [1.1, 2.1]} | math avg
to work. I guess that this is save to do for every math function (sin, exp, sum, ...)
Describe alternatives you've considered
No response
Additional context and details
This is a followup to #18749 and its solution #18754.
Basics
Related problem
The math functions recurse inconsistently into stacked data structures.
For example the "scalar input" functions
math abs,math ceil,math floorrecurses into lists inside records:but not into records inside records:
This is inconsistent.
Similar
but
which is contrary to what I as a user would expect how
| math FUNCbehaves.Describe the solution you'd like
Make
equivalent to
(and similarily if a cell path is given), i.e. the application of
| math FUNCrecurses into the record structure. This would then allowto work. I guess that this is save to do for every math function (sin, exp, sum, ...)
Describe alternatives you've considered
No response
Additional context and details
This is a followup to #18749 and its solution #18754.