Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

(tye)Re2: Why Closures?

by tye (Sage)
on Apr 26, 2001 at 21:45 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-24 04:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found