mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 23:27:45 +00:00

Deprecates the existing `stdlib-candidate` directories in `nu_scripts` since `std-rfc` has now transitioned to the main repo. Updates readme and renamed directories.
11 lines
294 B
Text
11 lines
294 B
Text
# A command to flatten many levels by using recursion
|
|
# by @jturner 2/10/21
|
|
# Example: sys | flatter 3
|
|
def flatter [levels:int] {
|
|
let input = $in
|
|
if $levels > 0 {
|
|
$input | columns | reduce -f $input {|it acc| $acc | flatten $it } | flatter ($levels - 1)
|
|
} else {
|
|
$input
|
|
}
|
|
}
|