This is basically what you want:
julia> QI = reinterpret(Int,Q)
20000-element Array{Int64,1}:
1
2
1
2
1
julia> sub(QI,2:2:length(QI))
10000-element SubArray{Int64,1,Array{Int64,1},(Range{Int64},)}:
2
2
2
2
2
This is even a sneaky way to mutate an instance of Q:
julia> sub(QI,2:2:length(QI))[1] = 3
3
julia> Q
10000-element Array{T,1}:
T(1,3)
T(1,2)
T(1,2)
T(1,2)
T(1,2)
On Tue, Jan 14, 2014 at 11:19 PM, Jonathan Malmaud <[email protected]>wrote:
> Say I have code like
>
> immutabe T
> x::Int
> y::Int
> end
>
> Q=fill(T(1,2),10000)
>
> I want to essentially construct
>
> W = [t.y for t in Q]
>
> The list comprehension method seems inefficient, since W is really just a
> strided view of Q with a stride and offset of 64 bits. Is there any
> convenient syntax to construct W that takes advantage of that fact?
>
>