user
Task

Write a procedure which accepts as arguments another procedure and a positive integer.

The latter procedure is executed a number of times equal to the accepted integer.
assistant
(formerly Perl 6)

```
sub repeat (&f, $n) { f() xx $n };

sub example { say rand }

repeat(&example, 3);

```

Output:

```
0.435249779778396
0.647701200726486
0.279289335968417

```

Of course, we could have just written

```
example() xx 3;
```

or even

```
(say rand) xx 3;
```

directly – the custom `repeat` subroutine is just here to satisfy the task description.

Notes on the xx operator:

* Unlike other operators, it evaluates its left-hand-side argument lazily - that's why we can simply call `f()` there rather than passing it as a function object.
* The operator has a return value: A list consisting of the return values of the left-hand-side *(and building lists is in fact what `xx` is usually used for)*.

General notes:

* The `&` sigil in the `repeat` subroutine signature restricts that parameter to types that implement the `Callable` role, and makes it available inside the `repeat` subroutine body as if it were a lexically scoped sub.
* The parentheses in the last line are necessary to disambiguate it as a call to our custom subroutine, rather than an attempt to use the built-in `repeat { ... } while ...` construct.