Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Can i do math with the elements of an array?

by zentara (Archbishop)
on Oct 20, 2011 at 14:33 UTC ( [id://932683]=note: print w/replies, xml ) Need Help??


in reply to Can i do math with the elements of an array?

You can loop thru your array or map the array, and perform whatever math you want on each element. But if you are talking about math operations on the ENTIRE array, you are looking at vector math. See PDL, it's piddles are arrays which can have math done on the entire array in one step. See PDL homepage and The PDL Newbook tutorial

But here is a simple map usage:

#!/usr/bin/perl use strict; use warnings; my @array = ( 1..10 ); print "@array\n"; my @mult = map { $_ * 2 } @array; print "@mult\n";

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-25 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found