September 2017
Beginner
402 pages
9h 52m
English
Preparing data lists can be very expressively organized with a pair of keywords in Perl 6—gather and take. The easiest way to understand how that works is by taking a look at the following example:
my @data = gather { take 'a'; take 'b';}say @data;
The block of code after the gather keyword returns a sequence that is saved in the @data array. The elements of the sequence are provided by the take keywords. So, there will be two elements in @data, as you can see here:
[a b]
Let's consider a bigger example. It contains a two-dimensional matrix of integer numbers and a list of instructions. The instructions are the four directions—left, right, up, and down, and a command— take-it. You should start at the ...
Read now
Unlock full access