Hi. Suppose I have an array X = [1 2 3 4]. I want to efficiently produce another array: [1 1 1 2 2 2 3 3 3 4 4 4] by repeating N times each element of X. How should I do this?
julia> v = randn(3)3-element Float64 Array:-0.89917-0.2555391.57712julia> [v[div(i,3)+1] for i=0:3*length(v)-1]9-element Any Array:-0.89917-0.89917-0.89917-0.255539-0.255539-0.2555391.577121.577121.57712
using Iterators
xs = [1 2 3 4]
for x in chain(map(x -> repeat(x, 3), xs)...)
println(x)
end