> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/perl6-rosettacode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/c/closures/value_capture.md).

# Value capture

All blocks are anonymous closures in Raku, and parameters are lexicals, so it's easy to generate a list of them. We'll use a `gather`/`take` generator loop, and call the closures in random order, just to keep things interesting.

```perl
my @c = gather for ^10 -> $i {
    take { $i * $i }
}

.().say for @c.pick(*);  # call them in random order
```

#### Output:

```
36
64
25
1
16
0
4
9
81
49
```

Or equivalently, using a more functional notation:

```perl
say .() for pick *, map -> $i { -> {$i * $i} }, ^10
```
