Open In App

Accessing every row and column of array in Julia – colon() Operator

Last Updated : 20 Jul, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The Colon() is an inbuilt operator in julia which is used to indicate and access every row and column. And also this operator is used to get index of specific element in the specified array.
Example 1: 
 

Python




# Julia program to illustrate
# the use of Colon (:) operator
 
# Indicating every row and column
Array1 = [1 2 "Hello"; 3 4 "Geeks"]
println(Array1[:, 3])
println(Array1[1, :])


Output: 
 

Example 2: 
 

Python




# Julia program to illustrate
# the use of Colon (:) operator
 
# Accessing every row and column
Array1 = cat([1 2; 3 4], 
              ["hello" "Geeks"; "Welcome" "GFG"], 
              [5 6; 7 8], dims = 3)
println(Array1[:, :, 3])
 
# Using getindex with colon operator
println(getindex(Array1, 1, :, 2))


Output: 
 

 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads