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
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

all for filters

Test if every element of the input fulfills a predicate expression.

Signature

> all {flags} (predicate)

Parameters

  • predicate: A closure that must evaluate to a boolean.

Input/output types:

inputoutput
list<any>bool

Examples

Check if a list contains only true values

> [false true true false] | all {}
false

Check if each row's status is the string 'UP'

> [[status]; [UP] [UP]] | all {|el| $el.status == UP }
true

Check that each item is a string

> [foo bar 2 baz] | all {|| ($in | describe) == 'string' }
false

Check that all values are equal to twice their index

> [0 2 4 6] | enumerate | all {|i| $i.item == $i.index * 2 }
true

Check that all of the values are even, using a stored closure

> let cond = {|el| ($el mod 2) == 0 }; [2 4 6 8] | all $cond
true