Julia seems broadcast/iterate array by elements:
arr = zeros(Float32, 3, 2)
for x in arr
println(x)
end
# output 6 lines of 0.0
I’m wondering if we can iterate normal arrays like numpy fashion, thus can we have:
arr = zeros(Float32, 3, 2)
for x in arr # or something others
println(x)
end
# output 3 lines of (0.0, 0.0)
I noticed that
arr = [[1,2],[3,4]]
for x in arr
println(x)
end
will produce
[1,2]
[3,4]
but type of arr
here is Array{Array{Int64,1},1}
, not Array{Int64, 2}
, and can not select element by arr[1,2]
.
As an summary, can we broadcast only on first dimension(or a specified dimension/axis) of an array?