Julia | checkbounds() function with examples
Last Updated :
06 Mar, 2020
The checkbounds()
is an inbuilt function in julia which is used to return true if the given index value lies within the bounds of the given array, otherwise returns false.
Syntax: checkbounds(Bool, Array, Index)
Parameters: This function accepts three parameters which are illustrated below:-
- Bool: This says that this function will return boolean values as output.
- Array: It is the given array with bounds
- Index: It is the index value which is going to be calculated either it lies in the array bounds or not.
Returns: It returns the value true if the index value lies in the array bounds else false.
Below are some codes which illustrate the above function:
Example #1:
A = rand( 1 , 10 );
Index = 5
A = checkbounds( Bool , A, Index)
println(A)
|
Output:
true
Example #2:
A = rand( 1 , 10 );
Index = 15
A = checkbounds( Bool , A, Index)
println(A)
|
Output:
false
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...