Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Perl Number range lookup question

by tobyink (Canon)
on Jun 18, 2012 at 17:34 UTC ( [id://976864]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl Number range lookup question
in thread Perl Number range lookup question

my $tier = $tiers{$n} //= calculate_tier($n);

That's a rather elegant memoization technique for functions in general (provided the function parameters can't be references). If your function took two parameters, you could even do:

my $tier = $tiers{$n, $m} //= calculate_tier($n, $m);

... taking advantage of Perl's rarely used multi-dimensional array fakery.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-23 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found