[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Adding together Perl Arrays

Posted on 2012-08-11
2
Medium Priority
?
773 Views
Last Modified: 2013-12-25
Can any one help me with the most efficient way to add together two arrays in Perl?

I have two arrays

my @Degre = map {rand(360)} (0..1999);
my @step= map {rand(.5)} (0..1999);

Open in new window


and have tried the following two methods to combine them

@Degre = map {$Degre[$_] + $step[$_]}0..1999;

$Degre[$_] += $step[$_] for (0..1999);

Open in new window


both work fine and for 2000 elements would be fine, but for 20,000 its starting to get slow and any thing above that its not very quick at all.

Are there any better / more efficient ways to combine arrays than cycling through them like this?

Cheers
0
Comment
Question by:Aaron Street
2 Comments
 
LVL 27

Accepted Solution

by:
wilcoxon earned 2000 total points
ID: 38284571
That's pretty much it unless you can find a special-purpose module on CPAN (I haven't heard of one for this but it may exist).
0
 
LVL 16

Author Comment

by:Aaron Street
ID: 38285931
OK, So now I know why modeling requires such high throughput computing power.

My mates 96 core blade server he does disease modeling on is starting to make perfect sense :) Cheers.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses
Course of the Month20 days, 13 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question