I'm interested in something similar, so Thanks Tomas and Tim.

Following on from Tomas original splice/insert method, and Tim's advice to 
wrap in function:

 function f3(a, w)
    local b = a[1:1+w] 
    for i in 2:length(a)-w
        splice!(b, 1)
        insert!(b, w+1, a[i+w]) 
    end
    b
end

Results on Julia v0.3.4:

julia> @time f1(a,w);
elapsed time: 0.262851198 seconds (613990480 bytes allocated, 66.49% gc time
)
julia> @time f2(a,w);
elapsed time: 0.061057112 seconds (55163280 bytes allocated, 54.16% gc time)
julia> @time f3(a,w);
elapsed time: 0.009859348 seconds (11840 bytes allocated)

Interesting to know comparison of f3() on Julia v0.4?

- Greg

Reply via email to