Hi, I am trying to understand how to use eachindex with an array.  For 
example, I can do:

julia> A = zeros(Int, (3,2))
3x2 Array{Int64,2}:
 0  0
 0  0
 0  0

followed by:
julia> for iter in eachindex(A)
                  @show iter.I[1], iter.I[2]
                  @show A[iter]
              end
ERROR: type Int64 has no field I
 [inlined code] from show.jl:127
 in anonymous at no file:0



However, using:
julia> A = sprand(2, 3, 0.5)
2x3 sparse matrix with 2 Float64 entries:
        [1, 1]  =  0.599423
        [2, 2]  =  0.340233

julia> for iter in eachindex(A)
                  @show iter.I[1], iter.I[2]
                  @show A[iter]
              end
(iter.I[1],iter.I[2]) = (1,1)
A[iter] = 0.5994230074532017
(iter.I[1],iter.I[2]) = (2,1)
A[iter] = 0.0
(iter.I[1],iter.I[2]) = (1,2)
A[iter] = 0.0
(iter.I[1],iter.I[2]) = (2,2)
A[iter] = 0.3402329840051479
(iter.I[1],iter.I[2]) = (1,3)
A[iter] = 0.0
(iter.I[1],iter.I[2]) = (2,3)
A[iter] = 0.0

works just fine.  I'm sure it's something simple, but at this stage would 
appreciate some help.

Reply via email to