Skip to content

Instantly share code, notes, and snippets.

Created July 11, 2013 16:53
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/5977186 to your computer and use it in GitHub Desktop.
Save anonymous/5977186 to your computer and use it in GitHub Desktop.
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