Created
July 11, 2013 16:53
-
-
Save anonymous/5977186 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
proto ndr(*@args, Int:D :$radix where $radix>0=10) {*}; | |
multi ndr(@vals where all(@vals) >>~~>> Int, Int :$radix) { | |
1+floor log (1 max [max] @vals>>.abs), $radix | |
}; | |
multi ndr(Int:D $val, Int :$radix) { | |
ndr [$val], radix=>$radix | |
}; | |
multi ndr(Int:D $val1, Int:D $val2, Int :$radix) { | |
ndr [$val1 + $val2], radix=>$radix | |
} | |
say ndr(256, 1, radix=>16); | |
# This works fine. Now, how do I allow the proto to | |
# govern subs with any number of positional parameters | |
# preceding the Int $radix ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment