Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Language Reference Guide
    • Readme
    • Types in the Nu Language
      • Basic Types
        • Any
        • Boolean
        • Integer
        • Float
        • Filesize
        • Duration
        • Datetime
        • Range
        • String
        • Record
        • List
        • Table
        • Closure
        • Nothing
        • Binary
        • Glob
        • Cell-Path
      • Other Data Types

        • Types that cannot be used to declare variables
          • Path
        • Types which are not declarable
          • Error
          • CustomValue
          • Block
      • Type signatures
      • Commands that interact with types
    • Operators
    • Flow control
      • if/else
      • loop
      • while
      • match
      • try/catch
      • break
      • return
      • continue
    • Filters
      • each and par-each
      • Filters to select subsets of data
      • where and filter
      • Understanding the difference between get and select
    • Custom Commands
    • Declarations
    • Variable Scope
    • Strings and Text Formatting
    • Helpers and debugging commands
    • Pipelines
    • MIME Types for Nushell

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

  1. A list is like a vector or array list in other languages.
  2. 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
  • each, par-each, filter, reduce
  • skip, skip until, skip while, take, take until, take while
  • first, last, length
  • insert, update, upsert, append See also the to (subcommands) and from (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
Edit this page on GitHub
Contributors: NotTheDr01ds, fdncred, Squidroot2
Prev
Record
Next
Table