Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: subtractionn in an array

by roboticus (Chancellor)
on Mar 21, 2012 at 16:51 UTC ( [id://960814]=note: print w/replies, xml ) Need Help??


in reply to subtractionn in an array

brackysclereid:

my $first_item = $List[0]; my $fifth_item = $List[4]; print $fifth_item-$first_item, "\n";

Update:

for my $idx = (1 .. $#List) { my $val = $List[$idx] - $List[$idx-1]; print "List[n] - List[n-1] = ", $val, " for n=", $idx, "\n"; }

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-19 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found