-1

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?

Qwerty
  • 869
  • 1
  • 5
  • 18
  • 1
    Does this answer your question? [How to repeat elements in list n times?](https://stackoverflow.com/questions/60234868/how-to-repeat-elements-in-list-n-times) – ccl Mar 28 '20 at 06:59
  • yes it helps me – Qwerty Mar 28 '20 at 10:04

1 Answers1

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