Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: "Junkyard" Puzzle: Average of Numbers

by jmcnamara (Monsignor)
on May 14, 2001 at 02:04 UTC ( #80113=note: print w/ replies, xml ) Need Help??


in reply to "Junkyard" Puzzle: Average of Numbers


This is 37 chars. I saw Abigail do something like this on clpmisc:

sub average1 { local$"="+";eval("@{$_[0]}")/@{$_[0]} }
This looks prettier when dealing with an ordinary list:
sub average2 { local$"="+";eval("@_")/@_ }
In which case this would be shorter:
sub average3 { eval(join"+",@_)/@_ }
The last one is the same as no_slogan's.

John.
--


Comment on Re: "Junkyard" Puzzle: Average of Numbers
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-12-26 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (167 votes), past polls