Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Subtraction by digit

by eric256 (Parson)
on Feb 11, 2008 at 17:11 UTC ( [id://667418]=note: print w/replies, xml ) Need Help??


in reply to Subtraction by digit

Some code would have been nice, but you can try push( @c, shift(@a) - shift(@b)) while (@a and @b); It is destructive, but @c will contain the results when it is done and it.

or a non-descructive version  $c[$_] =  $a[$_] - $b[$_] for  0 ..  ($#a <  $#b ? $#a : $#b);, but I think the first is easier to read. ;)

Updated thanks to some comments from ysth regarding precedence and a typo )


___________
Eric Hodges

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found