Created
April 7, 2016 01:58
-
-
Save awwaiid/ca6a33b419ac8a03b0f753ddb46783c4 to your computer and use it in GitHub Desktop.
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 "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"; |
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
hello | |
10011010001 | |
111 | |
0 | |
goodbye |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment