Tutorial by Examples

julia> sub2ind((3,3), 1, 1) 1 julia> sub2ind((3,3), 1, 2) 4 julia> sub2ind((3,3), 2, 1) 2 julia> sub2ind((3,3), [1,1,2], [1,2,1]) 3-element Array{Int64,1}: 1 4 2
# no error, even the subscript is out of range. julia> sub2ind((3,3), 3, 4) 12 One cannot determine whether a subscript is in the range of an array by comparing its index: julia> sub2ind((3,3), -1, 2) 2 julia> 0 < sub2ind((3,3), -1, 2) <= 9 true

Page 1 of 1