take while
for filters> take while {flags} (predicate)
predicate
: the predicate that element(s) must matchinput | output |
---|---|
list<any> | list<any> |
table | table |
Take while the element is negative
> [-1-291] |take while {|x| $x<0 }
╭───┬────╮
│0│-1│
│1│-2│
╰───┴────╯
Take while the element is negative using stored condition
>letcond= {|x| $x<0 }; [-1-291] |take while$cond
╭───┬────╮
│0│-1│
│1│-2│
╰───┴────╯
Take while the field value is negative
> [{a:-1} {a:-2} {a:9} {a:1}] |take while {|x| $x.a<0 }
╭───┬────╮
│# │ a │
├───┼────┤
│0│-1│
│1│-2│
╰───┴────╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/take_while.html