Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Pushing Element Multiple Times to Array

by Anonyrnous Monk (Hermit)
on Feb 13, 2011 at 09:15 UTC ( #887840=note: print w/replies, xml ) Need Help??


in reply to Pushing Element Multiple Times to Array

while (my ($var, $cnt) = each %hash) { push @flat, ($var) x $cnt; }

Unlike with the respective map solution, this allows you to use self-documenting variable names, and it also scales better performance-wise (both memory and execution time).  (Some people still prefer to use map — presumably because it allows them to show they've grasped basic functional programming concepts (or so, I guess).)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://887840]
help
Chatterbox?
[vrk]: Hope he gets better soon.
[Discipulus]: hdb sorry i profit; is known that a prime number is never a figurate one nor the sumattion of two adjacent figurates of the same order? like 3th triangular+3th tetrahedric
[Discipulus]: if known where i can read about the matter?
[choroba]: he's not really sick, we just got nobody to look after him today
[Discipulus]: create an account for him; we are funny baby sitters ;=) come here child, want to listen the typeglob tale?
[vrk]: choroba Oh, that's good.
[vrk]: Discipulus I don't know much about prime numbers, but wouldn't that kind of an answer be in a graduate-level number theory book?
[Discipulus]: my 8 yo daughter has two weeks of sleep disturbs.. we are gonna be crazy..

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-04-27 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (501 votes). Check out past polls.