Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: array => hash of occurrence indexes

by BrowserUk (Pope)
on Sep 11, 2013 at 11:17 UTC ( #1053464=note: print w/ replies, xml ) Need Help??


in reply to array => hash of occurrence indexes

Not so much shorter, but avoids the 5.12 dependency:

sub occurs{ my %h; push @{ $h{ $_[$_] } }, $_ for 0 .. $#_; return \%h };; pp occurs( 2, 1, 3, 4, 3, 4, 4, 5 );; { 1 => [1], 2 => [0], 3 => [2, 4], 4 => [3, 5, 6], 5 => [7] }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
/blockquote


Comment on Re: array => hash of occurrence indexes
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2014-07-11 01:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (217 votes), past polls