Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Printf in perl / Lazy hash possible?

by diotalevi (Canon)
on Aug 29, 2007 at 15:40 UTC ( #635826=note: print w/replies, xml ) Need Help??


in reply to Printf in perl / Lazy hash possible?

This is trivial. Store a delayed computation.

%hash = ( key => sub { value() } );

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^2: Printf in perl / Lazy hash possible?
by EvanCarroll (Chaplain) on Sep 03, 2007 at 07:47 UTC
    This is actually the conclusion that I arrived at too, but it seems ugly. I'll post again, and present this as a "How would you write the following code".


    Evan Carroll
    www.EvanCarroll.com

      It's only ugly because you're using perl. If you were in another language where you were used to seeing "lambda" all the time in user code it'd be ordinary. If you were using Haskell you wouldn't even have to be explicit about it. Since you're using Perl, you've got to live with what you've got. Or enact dizzying schemes of fantastic magicalism. I hope all that machinery is worth it just to get rid of the sub { ... }.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2020-10-25 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (249 votes). Check out past polls.

    Notices?