You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My first instinct coming from Matlab is to write loops like this:
for i in1:length(A[:,1])
end
If I come across size elsewhere in the documentation, then I might switch to the better:
for i in1:size(A,1)
end
However, neither of the above should really be used. pairs and axes are usually suggested on Discourse instead, but these function names are not intuitive to search for or use in this context. It would be nice to explain when to use the many different indexing functions available in Julia and their interaction with CartesianIndices.
Another topic that should be addressed in this section is the correct syntax order for accessing arrays in column order. In the examples below, the loop order of nested! and comprehension are natural to me, but the loop order of nested_compact! seems backwards. Since it is not obvious how the loops unwrap, it should be documented.
functionnested!(A)
for k inaxes(A,3)
for j inaxes(A,2)
for i inaxes(A,1)
A[i,j,k] = A[i,j,k] -1.0endendendendfunctionnested_compact!(A)
for k inaxes(A,3), j inaxes(A,2), i inaxes(A,1)
A[i,j,k] = A[i,j,k] -1.0endendfunctioncomprehension(A)
B = [A[i,j,k] +1.0for i inaxes(A,1), j inaxes(A,2), k inaxes(A,3)]
end
The text was updated successfully, but these errors were encountered:
Hopefully someday. I have DataFrames documentation that I need to finish first, and I still don't totally understand how pairs and CartesianIndices are supposed to be used.
https://docs.julialang.org/en/v1/manual/arrays/#Iteration
The documentation here needs a section on iterating over slices of an array.
My first instinct coming from Matlab is to write loops like this:
If I come across
size
elsewhere in the documentation, then I might switch to the better:However, neither of the above should really be used.
pairs
andaxes
are usually suggested on Discourse instead, but these function names are not intuitive to search for or use in this context. It would be nice to explain when to use the many different indexing functions available in Julia and their interaction withCartesianIndices
.Another topic that should be addressed in this section is the correct syntax order for accessing arrays in column order. In the examples below, the loop order of
nested!
andcomprehension
are natural to me, but the loop order ofnested_compact!
seems backwards. Since it is not obvious how the loops unwrap, it should be documented.The text was updated successfully, but these errors were encountered: