List
Description: | Ordered sequence of zero or more values of any type |
Annotation: | list |
Literal syntax: | See below |
Casts: | N/A |
See Also: | Working with Tables |
Navigating and Accessing Structured Data | |
Types of Data - Tables |
List-literal Syntax
List syntax is very similar to that of arrays in JSON. However, commas are not required to separate values when Nushell can easily distinguish them. The values of a list may be delimited by:
Commas
> [ foo, bar, baz ] ╭───┬─────╮ │ 0 │ foo │ │ 1 │ bar │ │ 2 │ baz │ ╰───┴─────╯
Spaces (when unambiguous):
> [ foo bar baz ] ╭───┬─────╮ │ 0 │ foo │ │ 1 │ bar │ │ 2 │ baz │ ╰───┴─────╯
Line breaks:
> [ foo bar baz ] ╭───┬─────╮ │ 0 │ foo │ │ 1 │ bar │ │ 2 │ baz │ ╰───┴─────╯
Additional Language Notes
- A list is like a vector or array list in other languages.
- A list uses 0-based indexing to retrieve values.
Common commands that can be used with list
Since lists, records and tables form the backbone of Nushell's structured nature, there are too many commands to list here. Here are a few:
any
all
get
select
get
each
,par-each
,filter
,reduce
skip
,skip until
,skip while
,take
,take until
,take while
first
,last
,length
insert
,update
,upsert
,append
See also theto (subcommands)
andfrom (subcommands)
for more examples.where
match
- Can destructure a list
Common operators that can be used with list
- in For set membership
not (12 in [1 2 3])
for inverse set membership