This file contains 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
class Tree { | |
has $.node; | |
has @.children; | |
method new($node, *@children) { self.bless(*, :$node, :@children) } | |
method Str { | |
@.children ?? "$.node: [@.children.join(", ")]" !! $.node.Str | |
} | |
method iterator() { | |
my sub traverse(Tree $t) { |
This file contains 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
class SolIter is Iterator { | |
has $!value; | |
has $!max; | |
has $!excludes_max; | |
has $!last_flag; | |
has $!next-iter; | |
multi method new(Range $r) { | |
self.bless(*, :value($r.excludes_min ?? $r.min.succ !! $r.min), | |
:max($r.max), |
This file contains 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 1...10 | |
12345678910 | |
> say (1...10)[3] | |
4 | |
> say (1...10)[0..3] | |
5 | |
> say (1...10)[0..4] | |
6 | |
> say (1...10)[1..4] | |
5 |
This file contains 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
S02-builtin_data_types/array_extending.t 19 - join on extended array | |
S03-junctions/misc.rakudo passed 48 unplanned test(s) | |
S03-metaops/cross.rakudo aborted 11 test(s) | |
S05-metasyntax/angle-brackets.rakudo 35 - strings are treated as a subrule in <@foo> | |
S05-metasyntax/angle-brackets.rakudo 36 - Regexes are left alone in <@foo> subrule | |
S05-substitution/subst.rakudo passed 39 unplanned test(s) | |
S05-transliteration/trans.rakudo 5 - If the last character is a dash it isn't part of a range | |
S05-transliteration/trans.rakudo 14 - Ranges can be grouped | |
S05-transliteration/trans.rakudo 15 - Multiple ranges interpreted in string | |
S05-transliteration/trans.rakudo 16 - Spaces in interpreted ranges are not skipped (all spaces are important) |
This file contains 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
Failure summary: | |
S02-builtin_data_types/array_extending.t 19 - join on extended array | |
S03-metaops/cross.rakudo aborted 11 test(s) | |
S05-metasyntax/angle-brackets.rakudo 35 - strings are treated as a subrule in <@foo> | |
S05-metasyntax/angle-brackets.rakudo 36 - Regexes are left alone in <@foo> subrule | |
S06-signature/introspection.rakudo passed 27 unplanned test(s) | |
S06-signature/named-parameters.rakudo 67 - exactly 2 arguments were slurped | |
S06-signature/named-parameters.rakudo 68 - sky argument was slurped | |
S09-typed-arrays/arrays.rakudo passed 7 unplanned test(s) | |
S12-class/open.t aborted 2 test(s) |
This file contains 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 sine-power($x) { | |
my $sign = 1; | |
my $x-part = $x; | |
my $denom = 1; | |
gather for 3, 5 ... * -> $n { | |
take $sign * $x-part / $denom; | |
$sign *= -1; | |
$x-part *= $x * $x; | |
$denom *= $n * ($n - 1); | |
} |
This file contains 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
my $factor = @lhs[*-2] / @lhs[*-3]; | |
if $factor ~~ Rat && $factor.denominator == 1 { | |
$factor = $factor.Int; | |
} | |
$next = { $_ * $factor }; |
This file contains 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
our multi sub infix:<div>(Int $a, Int $b) { | |
pir::div__III($a, $b) - ((($a < 0) ?^ ($b < 0)) ?& ?($a % $b)).Int; | |
} |
This file contains 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
use v6; | |
sub n($num){ | |
[+] $num.comb(/\d/).map: * ** 2 | |
} | |
sub isHappy($num){ | |
my $seen = 0; | |
for $num, &n ... * { | |
when $seen { return False } |
This file contains 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
my $iter = (1..10000).list; | |
my $a = 1; | |
while $iter.shift { | |
$a++; | |
} | |
say $a; |