Skip to content

Instantly share code, notes, and snippets.

@hughsimpson
hughsimpson / troll.p6
Created Dec 24, 2015
countdown numbers game (needs an input csv of the form `a,b,c,d` for the generating numbers
View troll.p6
sub getPartial(Str $a, Rat $x, Rat $y) {
my @comps = $x + $y, $x *$y, $x - $y, $x ** $y, $x / $y;
my @agg = "($a " «~« <+ * - ** /> »~» " $y)";
return @comps Z=> @agg
}
sub comp(@ps, %a) {
if @ps.elems == 0 {return %a}
my ($h, @t) = @ps;
if %a.elems == 0 {return comp(@t, $h => $h.Str)}