| title | any |
|---|---|
| categories | filters |
| version | 0.110.0 |
| filters | Tests if any element of the input fulfills a predicate expression. |
| usage | Tests if any element of the input fulfills a predicate expression. |
| editLink | false |
| contributors | false |
any for filters
Tests if any element of the input fulfills a predicate expression.
> any {flags} (predicate)
predicate: A closure that must evaluate to a boolean.
| input | output |
|---|---|
| list<any> | bool |
Check if a list contains any true values
> [false true true false] | any {}
trueCheck if any row's status is the string 'DOWN'
> [[status]; [UP] [DOWN] [UP]] | any {|el| $el.status == DOWN }
trueCheck that any item is a string
> [1 2 3 4] | any {|| ($in | describe) == 'string' }
falseCheck if any value is equal to twice its own index
> [9 8 7 6] | enumerate | any {|i| $i.item == $i.index * 2 }
trueCheck 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