I am very new to Julia, but here is my guess :
- for i = , j =
should be the same as
for i =
for j =
It would be awkward to have something else.
- For comprehensions, the order is the other way around because matrices
are stored in Julia in column order as in Fortran (and maybe Matlab) as
opposed to C. Therefore, ordering the comprehension that way make the
filling of the array cache-friendly.
François
On Friday, May 16, 2014 10:52:22 PM UTC+2, Peter Simon wrote:
>
> Comprehensions and for loops do not perform nested looping in the same
> order:
>
> julia> [begin println((i,j)); (i,j) end for i = 1:3, j = 1:4]
> (1,1)
> (2,1)
> (3,1)
> (1,2)
> (2,2)
> (3,2)
> (1,3)
> (2,3)
> (3,3)
> (1,4)
> (2,4)
> (3,4)
> 3x4 Array{(Int64,Int64),2}:
> (1,1) (1,2) (1,3) (1,4)
> (2,1) (2,2) (2,3) (2,4)
> (3,1) (3,2) (3,3) (3,4)
>
>
> julia> for i = 1:3, j=1:4
> println((i,j))
> end
> (1,1)
> (1,2)
> (1,3)
> (1,4)
> (2,1)
> (2,2)
> (2,3)
> (2,4)
> (3,1)
> (3,2)
> (3,3)
> (3,4)
>
>
>
> Just wondering what the rationale is for this difference.
>
> --Peter
>