in reply to Re (tilly) 2: Why Closures?
in thread Why Closures?
If Perl were a functional programming language, I would expect this:
to be easier to write than this:my @twice= map $doubler->($_), @list; my @thrice= map $tripler->($_), @list;
I never said Perl doesn't let you use functional programming techniques (in fact, I said the opposite).my @twice= map 2*$_, @list; my @thrice= map 3*$_, @list;
Perl just has a preference for non-functional techniques. map is one example. If you happen to have a closure, then map requires you to write more code. If Perl were a functional programming language, then you'd probably have to create a closure if you had a code block that you wanted to use with map.
- tye (but my friends call me "Tye")
|
---|