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 9:35

>>12
Assembly allows you to do certain things more easily than PHP and Perl.

Admit it; we can say Perl is better than PHP in certain things (like ||, well said) but this is not one of them. Perl functions are a hack the kind you find in shell scripting; they are syntactically terrible, you have to repeat the same patterns by hand, default values are verbose, they are terrible for documenting, and it just feels like a kick in the stomach. You know, I wanted to learn a language for quick shell hacks, and started with Perl. When I reached functions and "my" variables, I switched over to PHP.

Python's model is even more elegant: you have named parameters, defaulted parameters, callee can receive the remaining parameters/named parameters in a list/hash and caller can send them from a list/hash as parameters/named parameters,

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