Skip to content

Instantly share code, notes, and snippets.

Created August 9, 2009 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/164660 to your computer and use it in GitHub Desktop.
Save anonymous/164660 to your computer and use it in GitHub Desktop.
class Int is also {
method postcircumfix:<[ ]> ($n) {
self +> $n % 2
}
method flip ($n) {
self +^ 2**$n
}
}
my Int $x = 42; # 0b0101010
say $x;
print "last 8 bit reverse: ";
print $x[$_] for 0..7;
say "";
$x .= flip 5;
say "$x "~ $x.WHAT;
$x .= flip 5; # No applicable candidates found to dispatch to for 'flip'
say "$x "~ $x.WHAT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment