in reply to Reflections on “Higher Order Perl” §1.1
sub binary (0|1 $n) { $n } sub binary ($n) { my $k = int($n/2); my $b = $n % 2; my $E = binary($k); return $E ~ $b; }
That's fantasy syntax, unless it was allowed in the last two weeks where I didn't have internet access. It might work along these lines:
multi binary ($n where 0|1) { $n } multi binary ($n) { my $k = int($n/2); my $b = $n % 2; my $E = binary($k); return $E ~ $b; }
When you post Perl 6 code these days it's worth trying it in Rakudo first, which supports all the features needed for the subroutine above (I would try it myself, but I'm currently on a machine where I can't install any programs :-/).
In Section
Meditations