my $z = 0;
my $z := 0;
my $z = 0;
say "Hello, World!"
say("Hello, World!")
say "Hello, World!"
my $i = 0; while (++$i <= SCALE) { }; say $i;
my $i := 0; while ($i := $i + 1) <= SCALE { }; say($i);
my $i = 0; while (++$i <= SCALE) { }; say $i;
my int $i = 0; while ($i = $i + 1) <= SCALE { }; say $i;
my int $i := 0; while ($i := $i + 1) <= SCALE { }; say($i);
use integer; my $i = 0; while (++$i <= SCALE) { }; say $i;
my $a := 0; my $b := 1; my $i = 0; while (++$i <= SCALE) { $a := $b }; say $a;
my $a := 0; my $b := 1; my $i := 0; while ($i := $i + 1) <= SCALE { $a := $b }; say($a);
use Data::Alias; alias my $a = 0; alias my $b = 1; my $i = 0; while (++$i <= SCALE) { alias $a = $b }; say $a;
my $s = ""; my $i = 0; while (++$i <= SCALE) { $s ~= "x" }; say $s.chars;
my $s := ""; my $i := 0; while ($i := $i + 1) <= SCALE { $s := $s ~ "x" }; say(nqp::chars($s));
my $s = ""; my $i = 0; while (++$i <= SCALE) { $s .= "x" }; say length($s);
my str $s = ""; my int $i = 0; while ($i = $i + 1) <= SCALE { $s = $s ~ "x" }; say $s.chars;
my str $s := ""; my int $i := 0; while ($i := $i + 1) <= SCALE { $s := $s ~ "x" }; say(nqp::chars($s));
use integer; my $s = ""; my $i = 0; while (++$i <= SCALE) { $s .= "x" }; say length($s);
my $i = 0; my $s = ~$i; while (++$i <= SCALE) { $s = ~$i }; say $s;
my $i := 0; my $s := ~$i; while ($i := $i + 1) <= SCALE { $s := ~$i }; say($s);
my $i = 0; my $s = "$i"; while (++$i <= SCALE) { $s = "$i" }; say $s;
my int $i = 0; my str $s = ~$i; while ($i = $i + 1) <= SCALE { $s = ~$i }; say $s;
my int $i := 0; my str $s := ~$i; while ($i := $i + 1) <= SCALE { $s := ~$i }; say($s);
use integer; my $i = 0; my $s = "$i"; while (++$i <= SCALE) { $s = "$i" }; say $s;
my $s = ""; my $i = 0; while (++$i <= SCALE) { $s ~= $i }
my $s := ""; my $i := 0; while ($i := $i + 1) <= SCALE { $s := $s ~ $i }
my $s = ""; my $i = 0; while (++$i <= SCALE) { $s .= $i }
my str $s = ""; my int $i = 0; while ($i = $i + 1) <= SCALE { $s = $s ~ $i }
my str $s := ""; my int $i := 0; while ($i := $i + 1) <= SCALE { $s := $s ~ $i }
use integer; my $s = ""; my $i = 0; while (++$i <= SCALE) { $s .= $i }
my @a; my $i = 0; while (++$i <= SCALE) { @a.push("x") }; my $s = @a.join; say $s.chars;
my @a; my $i := 0; while ($i := $i + 1) <= SCALE { nqp::push(@a, "x"); }; my $s := nqp::join("",@a); say(nqp::chars($s));
my @a; my $i = 0; while (++$i <= SCALE) { push @a, "x" }; my $s = join "" => @a; say length($s);
my @a; my $i = 0; while (++$i <= SCALE) { push @a, 1 }; say +@a;
my @a; my $i := 0; while ($i := $i + 1) <= SCALE { nqp::push(@a, 1) }; say(+@a);
my @a; my $i = 0; while (++$i <= SCALE) { push @a, 1 }; say scalar @a;
my @a; @a.push(42); my $i = 0; while (++$i <= SCALE) { @a.push(@a) }; say +@a;
my @a; nqp::push(@a, 42); my $i := 0; while ($i := $i + 1) <= SCALE { my $elems := nqp::elems(@a); my $j := 0; while $j < $elems { nqp::push(@a, @a[$j]); $j++; } }; say(+@a);
my @a; push @a, 42; my $i = 0; while (++$i <= SCALE) { push @a, @a }; say scalar @a;
my @a; my $i = 0; @a[$i] = $i; while (++$i <= SCALE) { @a[ $i ] = $i }; say @a[*-1];
my @a; my $i := 0; @a[$i] := $i; while ($i := $i + 1) <= SCALE { @a[ $i ] := $i }; say(@a[@a - 1]);
my @a; my $i = 0; $a[$i] = $i; while (++$i <= SCALE) { $a[ $i ] = $i }; say $a[-1];
my %h; my $i = 0; %h{$i} = $i; while (++$i <= SCALE) { %h{ $i } = $i }; say %h{$i - 1};
my %h; my $i := 0; %h{$i} := $i; while ($i := $i + 1) <= SCALE { %h{ $i } := $i }; say(%h{$i - 1});
my %h; my $i = 0; $h{$i} = $i; while (++$i <= SCALE) { $h{ $i } = $i }; say $h{$i - 1};
my $i = -SCALE || exit(0); Nil while ++$i; say $i;
my $i := -SCALE || nqp::exit(0); () while $i := $i + 1; say($i);
my $i = -SCALE || exit(0); () while ++$i; say $i;
my int $i = -SCALE || exit(0); Nil while $i = $i + 1; say $i;
my int $i := -SCALE || nqp::exit(0); () while $i := $i + 1; say($i);
use integer; my $i = -SCALE || exit(0); () while ++$i; say $i;
loop (my $i = 1; $i <= SCALE; ++$i) { }; say $i;
for (my $i = 1; $i <= SCALE; ++$i) { }; say $i;
loop (my int $i = 1; $i <= SCALE; $i = $i + 1) { }; say $i;
use integer; for (my $i = 1; $i <= SCALE; ++$i) { }; say $i;
for (1 .. SCALE) { }; say SCALE;
for (1 .. SCALE) { }; say SCALE;
my $a := 0; my $b := 1; for (1 .. SCALE) { $a := $b; }; say $a;
use Data::Alias; alias my $a = 0; alias my $b = 1; for (1 .. SCALE) { alias $a = $b; }; say $a;
my $a = 0; my $b = 1; for (1 .. SCALE) { $a = $b; }; say $a;
my $a = 0; my $b = 1; for (1 .. SCALE) { $a = $b; }; say $a;
my int $a = 0; my int $b = 1; for (1 .. SCALE) { $a = $b; }; say $a;
use integer; my $a = 0; my $b = 1; for (1 .. SCALE) { $a = $b; }; say $a;
my $i = 0; for (1 .. SCALE) { $i++ }; say $i;
my $i = 0; for (1 .. SCALE) { $i++ }; say $i;
my int $i = 0; for (1 .. SCALE) { $i = $i + 1 }; say $i;
use integer; my $i = 0; for (1 .. SCALE) { $i++ }; say $i;
my $s = ""; for (1 .. SCALE) { $s ~= "x" }; say $s.chars;
my $s = ""; for (1 .. SCALE) { $s .= "x" }; say length($s);
my str $s = ""; for (1 .. SCALE) { $s = $s ~ "x" }; say $s.chars;
use integer; my $s = ""; for (1 .. SCALE) { $s .= "x" }; say length($s);
my $x = "a"; my $y = ""; for (1 .. SCALE) { $y ~= ($x ~ $x) }; say $y.chars;
my $x = "a"; my $y = ""; for (1 .. SCALE) { $y .= ($x . $x) }; say length($y);
my str $x = "a"; my str $y = ""; for (1 .. SCALE) { $y = $y ~ $x ~ $x }; say $y.chars;
use integer; my $x = "a"; my $y = ""; for (1 .. SCALE) { $y .= ($x . $x) }; say length($y);
my @a; for (1 .. SCALE) { push @a, 1 }; say +@a;
my @a; for (1 .. SCALE) { push @a, 1 }; say scalar @a;
my @a; @a[ $_ ] = $_ for 0 .. SCALE; say @a[SCALE];
my @a; $a[ $_ ] = $_ for 0 .. SCALE; say @a[SCALE];
my %h; %h{ $_ } = $_ for 0 .. SCALE; say %h<SCALE>;
my %h; $h{ $_ } = $_ for 0 .. SCALE; say $h{SCALE};
say [+] 1 .. SCALE;
use List::Util "reduce"; say reduce { $a + $b } 1 .. SCALE;
say [+] (1 .. SCALE).comb>>.Int;
use List::Util "reduce"; say reduce { $a + $b } map { 0+$_ } map { split "" } 1 .. SCALE;
my $match = 1 == any(1 .. SCALE); my $fail = 0 == any(1 .. SCALE); say "{+?$match} {+?$fail}"
my $match = grep { 1 == $_ } 1 .. SCALE; my $fail = grep { 0 == $_ } 1 .. SCALE; say "$match $fail"
my $s = " " x SCALE ~ "x" x SCALE ~ " " x SCALE; my $result = ""; $result = $s.trim for 1 .. SCALE; say $result.chars;
my $s = " " x SCALE . "x" x SCALE . " " x SCALE; my $result = ""; ($result) = $s =~ /^\s*(.*?)\s*$/s for 1 .. SCALE; say length($result);
my $s = (1 .. SCALE).join: ", "; my $i; my @s = $s.split(", ") while ++$i <= SCALE; say +@s;
my @i; my $i := 0; while ($i := $i + 1) <= SCALE { nqp::push(@i, ~$i); }; my $s := nqp::join(", ", @i); $i := 0; my @s; while ($i := $i + 1) <= SCALE { @s := nqp::split(", ", $s) }; say(+@s);
my $s = join ", " => 1 .. SCALE; my $i; my @s; @s = split ", " => $s while ++$i <= SCALE; say scalar @s;
my $s = (1 .. SCALE).join: ", "; my @s = $s.split(/\s*\,\s*/) for 1 .. SCALE; say +@s;
my $s = join ", " => 1 .. SCALE; my @s = split /\s*,\s*/ => $s for 1 .. SCALE; say scalar @s;
my $y = chr(SCALE); my $n = chr(SCALE + 1); my $i = 0; while (++$i <= SCALE) {$y ~~ /<[\c0..\c[SCALE]]>/; $n ~~ /<[\c0..\c[SCALE]]>/ }
my $y := nqp::chr(SCALE); my $n := nqp::chr(SCALE + 1); my $i := 0; while ($i := $i + 1) <= SCALE { $y ~~ /<[\c0..\c[SCALE]]>/; $n ~~ /<[\c0..\c[SCALE]]>/ }
my $y = chr(SCALE); my $n = chr(SCALE + 1); my $c = sprintf("%x",SCALE); my $reg="[\x00-\x{$c}]"; my $i = 0; while (++$i <= SCALE) { $y ~~ /$reg/; $n ~~ /$reg/; }
my $y = chr(SCALE); my $n = chr(SCALE + 1); my $i = 0; while (++$i <= SCALE) {$y ~~ /:i<[\c0..\c[SCALE]]>/; $n ~~ /:i<[\c0..\c[SCALE]]>/ }
my $y := nqp::chr(SCALE); my $n := nqp::chr(SCALE + 1); my $i := 0; while ($i := $i + 1) <= SCALE { $y ~~ /:i<[\c0..\c[SCALE]]>/; $n ~~ /:i<[\c0..\c[SCALE]]>/ }
my $y = chr(SCALE); my $n = chr(SCALE + 1); my $c = sprintf("%x",SCALE); my $reg="[\x00-\x{$c}]"; my $i = 0; while (++$i <= SCALE) { $y ~~ /$reg/i; $n ~~ /$reg/i; }
my $k = 0; my $i = 1; while ($i <= SCALE) { my $j = 1; while ($j <= SCALE) { $k = $i + $j; ++$j }; ++$i }; say $k
my $k := 0; my $i := 1; while ($i <= SCALE) { my $j := 1; while ($j <= SCALE) { $k := $i + $j; $j := $j + 1 }; $i := $i + 1 }; say($k)
my $k = 0; my $i = 1; while ($i <= SCALE) { my $j = 1; while ($j <= SCALE) { $k = $i + $j; ++$j }; ++$i }; say $k
my int $k = 0; my int $i = 1; while ($i <= SCALE) { my int $j = 1; while ($j <= SCALE) { $k = $i + $j; $j = $j + 1 }; $i = $i + 1 }; say $k
my int $k := 0; my int $i := 1; while ($i <= SCALE) { my int $j := 1; while ($j <= SCALE) { $k += $i + $j; $j := $j + 1 }; $i := $i + 1 }; say($k)
use integer; my $k = 0; my $i = 1; while ($i <= SCALE) { my $j = 1; while ($j <= SCALE) { $k = $i + $j; ++$j }; ++$i }; say $k
my $k = 0; loop (my $i = 1; $i <= SCALE; ++$i) { loop (my $j = 1; $j <= SCALE; ++$j) { $k = $i + $j } }; say $k;
my $k = 0; for (my $i = 1; $i <= SCALE; ++$i) { for (my $j = 1; $j <= SCALE; ++$j) { $k = $i + $j } }; say $k;
my int $k = 0; loop (my int $i = 1; $i <= SCALE; $i = $i + 1) { loop (my int $j = 1; $j <= SCALE; $j = $j + 1) { $k = $i + $j } }; say $k;
use integer; my $k = 0; for (my $i = 1; $i <= SCALE; ++$i) { for (my $j = 1; $j <= SCALE; ++$j) { $k = $i + $j } }; say $k;
my $k = 0; for 1 .. SCALE -> $i { for 1 .. SCALE -> $j { $k = $i + $j }; Nil }; say $k;
my $k = 0; for my $i (1 .. SCALE) { for my $j (1 .. SCALE) { $k = $i + $j }; 1 }; say $k;
my $k = 0; for flat(1 .. SCALE X 1 .. SCALE) -> $i, $j { $k = $i + $j }; say $k;
my $k := 0; sub mk2d($h, $w) { my $x := 1; my $y := 1; sub () { return () if $y > $h; my @c := ($y, $x); if ++$x > $w { $x := 1; ++$y; }; @c } }; my $it := mk2d(SCALE, SCALE); while $it() -> @c { $k := @c[0] + @c[1] }; say($k);
my $k = 0; sub mk2d { my ($h, $w) = @_; my $x = 1; my $y = 1; sub { return if $y > $h; my @c = ($y, $x); if (++$x > $w) { $x = 1; ++$y; }; @c } }; my $it = mk2d(SCALE, SCALE); while (my ($i, $j) = $it->()) { $k = $i + $j }; say $k;
my $k = 0; for (1 .. SCALE X 1 .. SCALE) -> ($i, $j) { $k = $i + $j }; say $k;
my (@src, @dst); @dst[0][0] = 0; for flat(1 .. SCALE X 1 ..SCALE) -> $i, $j { @src[$i][$j] = $i + $j }; for flat(1 .. SCALE X 1 .. SCALE) -> $i, $j { @dst[$i][$j] = @src[$i][$j] }; say @dst[SCALE][SCALE];
sub mk2d($h, $w) { my $x := 1; my $y := 1; sub () { return () if $y > $h; my @c := ($y, $x); if ++$x > $w { $x := 1; ++$y; }; @c } }; my @src; my @dst; my $it := mk2d(SCALE, SCALE); while $it() -> @c { @src[@c[0]] := [] unless @src[@c[0]]; @src[@c[0]][@c[1]] := @c[0] + @c[1] }; $it := mk2d(SCALE, SCALE); while $it() -> @c { @dst[@c[0]] := [] unless @dst[@c[0]]; @dst[@c[0]][@c[1]] := @src[@c[0]][@c[1]] }; say(@dst[SCALE][SCALE]);
sub mk2d { my ($h, $w) = @_; my $x = 1; my $y = 1; sub { return if $y > $h; my @c = ($y, $x); if (++$x > $w) { $x = 1; ++$y; }; @c } }; my (@src, @dst); $dst[0][0] = 0; my $it = mk2d(SCALE, SCALE); while (my ($i, $j) = $it->()) { $src[$i][$j] = $i + $j }; $it = mk2d(SCALE, SCALE); while (my ($i, $j) = $it->()) { $dst[$i][$j] = $src[$i][$j] }; say $dst[SCALE][SCALE];
my (@src, @dst); @dst[0][0] = 0; for (1 .. SCALE X 1 ..SCALE) -> ($i, $j) { @src[$i][$j] = $i + $j }; for (1 .. SCALE X 1 .. SCALE) -> ($i, $j) { @dst[$i][$j] = @src[$i][$j] }; say @dst[SCALE][SCALE];
my %h; my $m = 0; for ^SCALE { %h{$_} = $_ }; for %h.kv -> $k, $v { $m += $k == $v }; say $m;
my %h; my $m = 0; for (0 .. (SCALE - 1)) { %h{$_} = $_ }; while (my ($k, $v) = each %h) { $m += $k == $v }; say $m
my $r = 1.0; for 1 .. SCALE { $r *= $_; $r /= $_ + 1 }; say $r.numerator ~ "/" ~ $r.denominator;
use Math::BigRat; my $r = Math::BigRat->new(1); for (1 .. SCALE) { $r *= $_; $r /= $_ + 1 }; say $r->numerator . "/" . $r->denominator;
my $r = FatRat.new(0, 1); for 1 .. SCALE { $r += 1 / $_ }; say $r.perl
use Math::BigRat; my $r = Math::BigRat->new(0); for (1 .. SCALE) { $r += Math::BigRat->new(Math::BigInt->new(1), Math::BigInt->new($_)) }; say $r
my $total = 0; for ^SCALE { $total += rand }; say $total
my $total := 0; my $i := 0; while $i++ < SCALE { $total := $total + nqp::rand_n(1) }; say($total)
my $total = 0; for (1 .. SCALE) { $total += rand }; say $total
my @a = 0 xx SCALE; say +@a
my @a = (0) x SCALE; say scalar @a
$_ = "0" x 100 ~ "foo bar baz"; my $s = "foo bar baz"; loop (my $i = 0; $i < SCALE; $i++) { /$s/ }
$_ = ("0" x 100) . "foo bar baz"; my $s = "foo bar baz"; for (my $i = 0; $i < SCALE; $i++) { /\Q$s\E/ }