nushell/crates/nu-command/tests/commands
Andrés N. Robalino 803826cdcd
90 degree table rotations (clockwise and counter-clockwise) (#3086)
Also for 180 degree is expected. Rotation is not exactly like pivoting (transposing)
for instance, given the following table:

```
> echo [[col1, col2, col3]; [cell1, cell2, cell3] [cell4, cell5, cell6]]
───┬───────┬───────┬───────
 # │ col1  │ col2  │ col3
───┼───────┼───────┼───────
 0 │ cell1 │ cell2 │ cell3
 1 │ cell4 │ cell5 │ cell6
───┴───────┴───────┴───────
```

To rotate it counter clockwise by 90 degrees, we can resort to first transposing (`pivot`)
them adding a new column (preferably integers), sort by that column from highest to lowest,
then remove the column and we have a counter clockwise rotation.

```
> echo [[col1, col2, col3]; [cell1, cell2, cell3] [cell4, cell5, cell6]] | pivot | each --numbered { = $it.item | insert idx $it.index } | sort-by idx | reverse | reject idx
───┬─────────┬─────────┬─────────
 # │ Column0 │ Column1 │ Column2
───┼─────────┼─────────┼─────────
 0 │ col3    │ cell3   │ cell6
 1 │ col2    │ cell2   │ cell5
 2 │ col1    │ cell1   │ cell4
───┴─────────┴─────────┴─────────
```

Which we can get easily, in this case, by doing:

```
> echo [[col1, col2, cel3]; [cell1, cell2, cell3] [cell4, cell5, cell6]] | rotate counter-clockwise
───┬─────────┬─────────┬─────────
 # │ Column0 │ Column1 │ Column2
───┼─────────┼─────────┼─────────
 0 │ col3    │ cell3   │ cell6
 1 │ col2    │ cell2   │ cell5
 2 │ col1    │ cell1   │ cell4
───┴─────────┴─────────┴─────────
```

There are also many powerful use cases with rotation, it makes a breeze creating tables with many columns, say:

```
echo 0..12 | rotate counter-clockwise | reject Column0
───┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬──────────┬──────────┬──────────┬──────────
 # │ Column1 │ Column2 │ Column3 │ Column4 │ Column5 │ Column6 │ Column7 │ Column8 │ Column9 │ Column10 │ Column11 │ Column12 │ Column13
───┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┼──────────┼──────────
 0 │       0 │       1 │       2 │       3 │       4 │       5 │       6 │       7 │       8 │        9 │       10 │       11 │       12
───┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴──────────┴──────────┴──────────┴──────────
```
2021-02-22 06:56:34 -05:00
..
hash_
keep
math
move_
path
random
skip
str_ allow str from to convert more things to string (#2977) 2021-01-29 07:43:35 -06:00
append.rs
autoenv.rs
autoenv_trust.rs
autoenv_untrust.rs
cal.rs
cd.rs Replace dirs and directories with maintained (#2949) 2021-01-19 14:24:27 -06:00
compact.rs
count.rs
cp.rs
def.rs
default.rs
drop.rs
each.rs
echo.rs
empty.rs
enter.rs
every.rs
first.rs
flatten.rs
format.rs standardize on how to get file size (#2992) 2021-02-03 07:19:38 -06:00
get.rs
group_by.rs
headers.rs
histogram.rs
insert.rs
into_int.rs nu-parser + nu-protocol: switch to metric for KB, MB, GB, add KiB, MiB, GiB units (#3035) 2021-02-10 15:31:12 +13:00
last.rs
lines.rs
ls.rs
merge.rs
mkdir.rs
mod.rs 90 degree table rotations (clockwise and counter-clockwise) (#3086) 2021-02-22 06:56:34 -05:00
nth.rs
open.rs Soft rest arguments column path cohersions. (#3016) 2021-02-06 20:05:47 -05:00
parse.rs
prepend.rs
range.rs
reduce.rs
rename.rs
reverse.rs
rm.rs
rotate.rs 90 degree table rotations (clockwise and counter-clockwise) (#3086) 2021-02-22 06:56:34 -05:00
save.rs
select.rs Soft rest arguments column path cohersions. (#3016) 2021-02-06 20:05:47 -05:00
semicolon.rs
sort_by.rs
split_by.rs
split_column.rs
split_row.rs
touch.rs
uniq.rs
update.rs
where_.rs nu-parser + nu-protocol: switch to metric for KB, MB, GB, add KiB, MiB, GiB units (#3035) 2021-02-10 15:31:12 +13:00
which.rs Use equality assert macros (#2969) 2021-01-25 18:16:10 +13:00
with_env.rs
wrap.rs