nushell/crates
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
..
nu_plugin_binaryview Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_chart Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_fetch Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_from_bson Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_from_sqlite Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_inc Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_match Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_post Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_ps Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_s3 Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_selector Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_start Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_sys Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_textview Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_to_bson Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_to_sqlite Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_tree Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu_plugin_xpath Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-cli add the ability to time commands (#3081) 2021-02-20 07:37:14 -06:00
nu-command 90 degree table rotations (clockwise and counter-clockwise) (#3086) 2021-02-22 06:56:34 -05:00
nu-data Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-engine Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-errors Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-json Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-parser Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-plugin Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-protocol Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-source Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-stream Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00
nu-table this example now runs out of the box instead of failing with no value or the wrong value (#3067) 2021-02-19 21:40:53 +13:00
nu-test-support Extract .nu-env tests and more granularity (#3078) 2021-02-18 20:24:27 -05:00
nu-value-ext Bump to 0.27.1 (#3073) 2021-02-18 18:54:48 +13:00