Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
say "hello";
subset NWZ of Int where * > -1;
proto conversion(NWZ $x, $s = ""){*}
multi conversion(0, $s = "0") {
$s
}
multi conversion($x where * %% 2, $s) {
conversion($x div 2, "0" ~ $s)
}
multi conversion($x, $s) {
conversion($x div 2, "1" ~ $s)
}
multi conversion($x, $s = ""){
conversion($x, $s)
}
sub postfix:<xb>(NWZ $x) {
say "[$x]";
conversion($x);
}
# multi conversion(Any $x, |){
# conversion($x.Int)
# }
say conversion(1233);
say conversion(7);
# say conversion(-7);
say conversion(0);
#say (0)xb;
#say 0xb + 12;
#say conversion("14");
say "goodbye";
hello
10011010001
111
0
goodbye
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.