Advertisement
Guest User

protos in perl6

a guest
Jul 11th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.39 KB | None | 0 0
  1. proto ndr(Any, Int:D $radix where $radix>0=10) {*};
  2.  
  3. multi ndr(@vals where so all(@vals) >>~~>> Int, Int $radix)  {
  4.     1+floor log (1 max [max] @vals>>.abs), $radix
  5. };
  6.  
  7. multi ndr(Int:D $val, Int $radix) {
  8.     ndr [$val], $radix
  9. };
  10.  
  11. say ndr(257,16);
  12.  
  13. # This works fine.  Now, how do I allow the proto to
  14. # govern subs with any number of positional parameters
  15. # preceding the Int $radix ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement