Files
dotfiles/dot_config/nushell/nu_scripts/stdlib-candidate/std-rfc/tables/row-indices.nu
Cian Hughes 896af887ca Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
2024-11-07 13:52:17 +00:00

25 lines
544 B
Nu

use ../conversions/into.nu *
# Return a list of indices
# for the provided ranges or indices.
# Primarily used as a helper for
# "select ranges" et. al.
#
# Example:
#
# row-indices 0 2..5 7..8
# # => ╭───┬───╮
# # => │ 0 │ 0 │
# # => │ 1 │ 2 │
# # => │ 2 │ 3 │
# # => │ 3 │ 4 │
# # => │ 4 │ 5 │
# # => │ 5 │ 7 │
# # => │ 6 │ 8 │
# # => ╰───┴───╯
export def main [ ...ranges ] {
$ranges
| reduce -f [] {|range,indices|
$indices ++ ($range | into list)
}
}