Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

(tye)Re2: Why Closures?

by tye (Sage)
on Apr 26, 2001 at 21:45 UTC ( #75837=note: print w/replies, xml ) Need Help??

in reply to Re (tilly) 2: Why Closures?
in thread Why Closures?

If Perl were a functional programming language, I would expect this:

my @twice= map $doubler->($_), @list; my @thrice= map $tripler->($_), @list;
to be easier to write than this:
my @twice= map 2*$_, @list; my @thrice= map 3*$_, @list;
I never said Perl doesn't let you use functional programming techniques (in fact, I said the opposite).

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")

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://75837]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2020-01-23 01:42 GMT
Find Nodes?
    Voting Booth?