Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Request translation into Perl

Name: Anonymous 2006-06-26 10:56

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?

function f($i = 1, $r = 17) {
    return --$r <= 0 ? null : array($i => f($i + 2, $r), $i + 1 => f($i + 3, $r));
}

Thanks!

Name: Anonymous 2006-06-27 5:11

>>2
PHP. No, it's far nicer than Perl, but I used ?: .

>>5
It's not meant to be fast, it's meant to compare something and do it that way.

>>8
That's why I didn't bother with Perl. Don't you feel something reeks in

sub df { return defined($_[0])?$_[0]:$_[1]; }
sub f {
    my ($i,$r) = (df($_[0],1),df($_[1],17));

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List