Open In App

Getting tuple of indices in Julia – to_indices() Method

Last Updated : 21 Apr, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The to_indices() is an inbuilt function in julia which is used to convert the given tuple I to a tuple of indices for use in indexing into array A.

Syntax: to_indices(A, I::Tuple)

Parameters:

  • A: Specified array
  • I: Specified tuple

Returns: It returns the converted tuple of indices.

Example 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))


Output:

(10, 20, 30, 40)

Example 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))


Output:

(5, 10, 15, 20, 25)

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads