Skip to content
Related Articles

Related Articles

Improve Article

Checking for true values in an array in Julia – any() and all() Methods

  • Last Updated : 26 Mar, 2020

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:






# Julia program to illustrate 
# the use of any() method
  
# Getting 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.
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:




# Julia program to illustrate 
# the use of all() method
  
# Getting 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.
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:




My Personal Notes arrow_drop_up
Recommended Articles
Page :