Repeating (with function repeat) array elements using a vector of numbers

With reduce and FillArrays the performance is quite good

julia> using FillArrays, BenchmarkTools

julia> x,v = rand(100), rand(1:100, 100);

julia> @btime vcat(fill.($x, $v)...);
  9.296 μs (103 allocations: 80.70 KiB)

julia> @btime vcat(Fill.($x, $v)...);
  9.349 μs (206 allocations: 46.42 KiB)

julia> @btime reduce(vcat,Fill.($x, $v));
  3.760 μs (3 allocations: 36.97 KiB)
2 Likes