P15 - Replicate the elements of a list a given number of times.

Author: Ryan Connelly

Example

> say replicate(<a b c c d e>.list, 3);
a a a b b b c c c c c c d d d e e e

Source code: P15-topo.pl

use v6;

sub replicate(@list, $times)
{
    @list.map({$_ xx $times}).flat;
}

say "{replicate(<a b c c d e>.list, 3)}";