Checking for true values in an array in Julia – any() and all() Methods
The any()
is an inbuilt function in julia which is used to test whether any elements of the specified boolean collection are true and if any of the input value is ‘missing’, it will return missing if all non-missing values are false.
Syntax: any(itr)
Parameters:
- itr: Specified boolean collection.
Returns: It returns true if any of the value of specified boolean collection is true. And also return missing value if all non-missing values are false in the boolean collection.
Example 1:
println( any ([true, false, true, false]))
println( any ([true, true, true, true]))
println( any ([false, false, false, false]))
println( any ([missing, true, true]))
println( any ([false, missing, true]))
println( any ([false, missing, false]))
|
Output:
all()
all() is an inbuilt function in
julia which is used to test whether any elements of the specified boolean collection are true and if any of the input value is ‘missing’, it will return missing if all non-missing values are true.
Syntax:
all(itr)
Parameters:
- itr: Specified boolean collection.
Returns: It returns false if any of the value of specified boolean collection is false. And also return missing value if all non-missing values are true in the boolean collection.
Example 1:
println( all ([true, false, true, false]))
println( all ([true, true, true, true]))
println( all ([false, false, false, false]))
println( all ([missing, true, true]))
println( all ([false, missing, true]))
println( all ([false, missing, false]))
|
Output:
Last Updated :
26 Mar, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...