EXISTS
Description
The EXISTS function is used to determine whether there is an element in the specified array that meets the given condition. By passing in a lambda expression, each element in the array can be evaluated. If at least one element meets the condition, the function returns true; otherwise, it returns false.
Parameters
- array:
array<T>
type, representing the array to be evaluated. - x -> expr: A single-parameter lambda expression, where x corresponds to an element in the array; expr needs to return a boolean type, representing the condition to be evaluated.
Return Type
Returns a boolean value.
Example Usage
- Determine if there is an element in the array that is less than or equal to 3:
Results:
- Determine if there are elements in the array that are less than or equal to 0:
Result: Returns an empty string
- Determine if all elements in the array are less than or equal to 0:
Results:
- Determine if there is at least one null value in the array:
Results:
- Determine if there are even numbers in the array:
Results:
- Determine if there are negative numbers in the array:
Results: