📜  朱莉娅 |带有示例的 checkindex()函数

📅  最后修改于: 2022-05-13 01:55:17.915000             🧑  作者: Mango

朱莉娅 |带有示例的 checkindex()函数

checkindex()是 julia 中的内置函数,如果给定的索引值在范围内,则用于返回 true,否则返回 false。

以下是一些说明上述函数的代码:
示例 #1:

# Julia Program for illustration of
# checkindex() function
  
# Initializing a range value from 1 to 10
Range = 1:10
  
# Initializing a index value of 5
Index = 5
  
# Calling the checkindex() function
A = checkindex(Bool, Range, Index)
  
# Getting the value true or false
println(A)

输出:

true

示例 #2:

# Julia Program for illustration of
# checkindex() function
  
# Initializing a range value from 1 to 10
Range = 1:10
  
# Initializing a index value of 15
Index = 15
  
# Calling the checkindex() function
A = checkindex(Bool, Range, Index)
  
# Getting the value true or false
println(A)

输出:

false