Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

(tye)Re2: Why Closures?

by tye (Cardinal)
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")


Comment on (tye)Re2: Why Closures?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (17)
As of 2014-07-28 19:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (206 votes), past polls