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

Re^2: fibo's 66 chars

by Roy Johnson (Monsignor)
on May 27, 2009 at 21:17 UTC ( #766514=note: print w/ replies, xml ) Need Help??

in reply to Re: fibo's 66 chars
in thread fibo's 66 chars

Since you only use the parameter once, it's cheaper to just reference it as $ARGV[0] pop it inline rather than assign it to anything.

@b=(0,1);push@b,$b[-2]+$b[-1]for 2..pop;print$b[-2]
You can save fourteen more strokes (and, irrelevantly, memory) by not using an array and using convoluted scalar assignment with a variable that is pre-initialized:
$b=1;$?=($b+=$?)-$?for 2..pop;print$?

Caution: Contents may have been coded under pressure.

Comment on Re^2: fibo's 66 chars
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2015-11-29 18:24 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (752 votes), past polls