Reputation: 511
The repeat function in julia is used to replicate a vector a number of specified times. What if I want to repeat an integer instead of a vector?
For example,
repeat([1,2,3],3)
gives
9-element Array{Int64,1}: 1 2 3 1 2 3 1 2 3
What I want now is to repeat an integer many times. How is this possible?
Upvotes: 5
Views: 1392
Reputation: 16797
What is wrong with:
i = 4
repeat([i],6)
It gives:
6-element Array{Int64,1}:
4
4
4
4
4
4
Upvotes: 1
Reputation: 724
I think you may be looking for the fill
function.
i = 4
nr_repeats = 10
fill(i, nr_repeats)
Upvotes: 1