Actually, this was fixed in the latest version of the package, but it wasn't tagged, so I did that. The following works with the latest tagged version:
julia> collect(partition(list, 3, 1)) 3-element Array{(Int64,Int64,Int64),1}: (1,2,3) (2,3,4) (3,4,5) On Tue, Jun 17, 2014 at 7:34 PM, Kevin Squire <kevin.squ...@gmail.com> wrote: > (It's not clear to me how your answer matches the OP's request...?) > > The partition function in https://github.com/JuliaLang/Iterators.jl will > do this: > > > julia> using Iterators > > julia> list = [1,2,3,4,5] > 5-element Array{Int64,1}: > 1 > 2 > 3 > 4 > 5 > > julia> for p in partition(list, 3, 1) > println(p) > end > (1,2,3) > (2,3,4) > (3,4,5) > > Normally, "collect" will collect the elements of an iterable into an > array. In this case, though, there is a bug in Iterators.jl which causes > problems with this (the length of a partition is not defined properly.) > I'll fix this momentarily. > > Cheers, > Kevin > > > On Tue, Jun 17, 2014 at 7:27 PM, <yfrac...@gmail.com> wrote: > >> how about this? >> >> ``` >> julia> a = [1,2,3,10,20,30,100,200,300] >> >> julia> r = reshape(a,3,3) >> 3x3 Array{Int64,2}: >> 1 10 100 >> 2 20 200 >> 3 30 300 >> >> julia> r[:,1] >> 3-element Array{Int64,1}: >> 1 >> 2 >> 3 >> ``` >> > >