This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proto fringe($) { gather { {*} } } | |
multi fringe (Pair $node) { take fringe $_ for $node.kv } | |
multi fringe (Any $leaf) { take $leaf } | |
sub samefringe ($a, $b) { fringe($a) eqv fringe($b) } | |
my $a = 1 => 2 => 3 => 4 => 5 => 6 => 7 => 8; | |
my $b = 1 => (( 2 => 3 ) => (4 => (5 => ((6 => 7) => 8)))); | |
my $c = (((1 => 2) => 3) => 4) => 5 => 6 => 7 => 8; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub msb(Int $self) { | |
return Nil if $self == 0; | |
return 0 if $self == -1; | |
my $msb = 0; | |
my $x = $self; | |
$x = ($x + 1) * -2 if $x < 0; # handle negative conversions | |
while $x > 0xff { $msb += 8; $x +>= 8; } | |
if $x > 0x0f { $msb += 4; $x +>= 4; } | |
if $x +& 0x8 { $msb += 3; } | |
elsif $x +& 0x4 { $msb += 2; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub modmap (Int $x is copy, @rads) { | |
gather { | |
while $x and @rads { | |
my $rad = @rads.shift; | |
take $x % $rad; | |
$x div= $rad; | |
} | |
take $x if $x; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
say qq:to/END/; | |
Line 1 | |
{foo} | |
Line 4 | |
END | |
sub foo { " Line 2\nLine 3" } |