.say for ^2020;
.say given 'Wish list';
$_ = 42;
when 42 { say 'find it' };
for 42, 43, "foo", 44, "bar" {
when Int { .say }
when /:i ^Bar/ { .say }
default { say "Not an Int or a Bar" }
}
for Date.new('2019-01-01') .. Date.new('2019-02-04') {
printf("%04d%02d%02d\n", .year, .month, .day) given .DateTime
}
my @results = lazy '/usr/share/dict/SOWPODS'.IO.lines.grep: {
.chars ≤ 72 &&
.substr(0, 1) ∈ 'a' .. 'z' &&
.comb.Bag ⊆ 'A' .. 'Z'
}
my @year = <2019 2018 2012 2020>;
@year».chars;
my @lines = gather "/usr/share/dict/words".IO.lines».chars».take;
gather .take for <Nim Rust Perl>;
gather take 2 * $_ if $_ ** 2 > 19 for ^100;
gather .take when /7$/ for 1..99;
gather take $_ ** 2 for 1..10;
.say with 42
given '20190823' {
for ((1 .. .chars) ∖ .chars «-» .indices(0)).keys.sort(-*) -> $n {
say "{.substr(* - $n)} is prime" if .substr(* - $n).is-prime;
}
}
given open("output-perl6", :w) {
my $catFace = "\x1F639";
.say($catFace);
.say($catFace.chars);
my $dWithDots = "D\x0323\x0307";
.say($dWithDots);
.say($dWithDots.chars);
.close;
}