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

any for filters

Tests if any element of the input fulfills a predicate expression.

Signature

> any {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 any true values

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

Check if any row's status is the string 'DOWN'

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

Check that any item is a string

> [1 2 3 4] | any {|| ($in | describe) == 'string' }
false

Check if any value is equal to twice its own index

> [9 8 7 6] | enumerate | any {|i| $i.item == $i.index * 2 }
true

Check if any of the values are odd, using a stored closure

> let cond = {|e| $e mod 2 == 1 }; [2 4 1 6 8] | any $cond
true