📜  在 Julia 中获取索引元组 – to_indices() 方法

📅  最后修改于: 2021-11-25 04:39:54             🧑  作者: Mango

to_indices()是 julia 中的一个内置函数,用于将给定的元组 I 转换为索引元组,以用于索引到数组 A 中。

示例 1:

# Julia program to illustrate 
# the use of to_indices() method
  
# Getting the converted tuple of indices
A = [1, 2, 3, 4];
t = (10, 20, 30, 40);
println(to_indices(A, t))

输出:

(10, 20, 30, 40)

示例 2:

# Julia program to illustrate 
# the use of to_indices() method
  
# Getting the converted tuple of indices
A = [1, 2];
t = (5, 10, 15, 20, 25);
println(to_indices(A, t))

输出:

(5, 10, 15, 20, 25)