I'm testing something, and I'm stuck trying to write a Perl equivalent of this function because Perl's syntax is made of ugly, rudimentary, hack and fail. Could you please show me how to do this very simple thing in Perl?
A. Your function is ugly.
B. Perl doesn't do default values very nicely because it handles functions differently (since perl can do anonymous functions properly I'd argue that PHP's idea of a function is a joke)
C. You don't need "my". My declares scope so you should use it
D. PHP's array is absolute bullshit and your code expresses that
E. In perl we are using hashref
F. Your programming should reflect what you mean, not just that it fits on 3 lines
G. 16 is an absolute idiot. scope matters and spelling matters. In C your declaration declares scope, if you don't use my you aren't declaring the variable.
H. 4chan proves yet again that /prog/ is full of idiots.
sub f {
my ($i,$r) = @_;
$i = defined($i)?$i:1;
$r = defined($r)?$r:17;
--$r;
return undef if ($r <= 0);
return {
$i => f($i + 2, $r),
($i + 1) => f($i + 3, $r)
};
}