my @aa = 8 .. 12;
for @aa.kv -> $i, $_ { say "$i: $_" }
my $1 := my $b = 2;
no strict;
my $b = :2<11110000>;
# -> 240   ## A binary (base 2) number
my $a = :16<FF>;
# -> 255   ## A hexadecimal (base 16) number
my $b = :2("11110000");
# -> 240   ## A binary (base 2) number

Instrospection

for "azea".HOW.^attributes { .name.say }


# Candidates
say .signature for @arr.^method_table{'AT-POS'}.candidates;

Dispatch

call____ — call next matching candidate in the chain and come back here next____ — just go to next matching candidate in the chain and don’t come back ____same — use the same arguments as were used for current candidate ____with — make the operation with these new arguments provided samewith — make the same call from scratch, following a new dispatch chain, with these new arguments, and come back

Async

Types

Perl C
int8 int8_t, also used for char
int16 int16_t, also used for short
int32 int32_t, also used for int
int64 int64_t
uint8 uint8_t, also used for unsigned char
uint16 uint16_t, also used for unsigned short
uint32 uint32_t, also used for unsigned int
uint64 uint64_t
Long long
Longlong long Long, at least 64-bit
num32 float
num64 double
Str string
CArray[int32] int*, an array of ints
Pointer[void] void*, can point to all other types
bool bool from C99
size_t size_t
— | — | – | — |
package | grammar | module | role |
knowhow | enum | class | subset |

Module

String

IO::HANDLE

Array


# Reduce
my $sum = reduce { $^a + $^b }, 1..10;
say [+] 1, 2, 3,4;
# -> 10
say [\+] 1, 2, 3, 4;
# -> (1 3 6 10)
say [lt] <a b c d e>;
# -> True


# Map
map { $_ * 2 }, 1..10;
map $num -> { $num * 2 }, 1..10;
map { $^a * 2 }, 1..10;


# Filter
grep { /<[aeiouy]>/ }, @array;
grep {'uno'}, %eng2sp.values;

# Type
my Int @arr = 1...20;

# Shaped arrays
my @arr[12] = 22, 12;
# Fill with Any

Hash

say grep { .value == 2 }, %histo.pairs
%seen{$key}:exists
my %uniq = map { $_ => 1 }, @arr;
my %rev = %hash.kv.reverse;

HOW: Higher Order Working

Can be invoked with 'toto'.^methods