I have a fragment that I want to play. For example, if xs = [1, 2, 3]
, and I need to replicate it 4 times, I would end with ys = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
.
In Haskell, I would do something like this:
ys = take (4 * length xs) $ cycle xs
How can this be done similarly in Rust?
source
share