I want to repeat the numbers 48, 23, 45, 67 three times in Julia to get a 12-element array like 48, 23, 45, 67, 48, 23, 45, 67, 48, 23, 45, 67. How to get the expected output succinctly without having to type the elements multiple times?
Asked
Active
Viewed 686 times
1 Answers
2
The repeat(array, n)
function can be used to create an array with repeated values. To the first argument pass the numbers as an array and to the argument pass the number of times it is expected to be repeated.
julia> array = repeat([48, 23, 45, 67], 3)
12-element Array{Int64,1}:
48
23
45
67
48
23
45
67
48
23
45
67

Qwerty
- 869
- 1
- 5
- 18