in reply to RE: RE: RE: RE: Answer: How can I add all the numbers in an array with out doing a foreach loop?
in thread How can I add all the numbers in an array with out doing a foreach loop?
sub addArray{ shift(@_) + addArray(@_) if(@_) } $total = addArray( 1, 3, 8, 15, 7, 5, 3 )
Update: Two other things KM, I notice that you voted -- on my original comment. I'm not sure why. Nothing I said in that post was incorrect or rude. I also have noticed that my recursive answer is similar to the one that Btrott posted. I'm not sure why I should care, but I didn't want you to think I had copied it, as I had not read it when I first posted this. Cheers.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE (6) Adam: Answer: How can I add all the numbers in an array with out doing a foreach loop?
by nuance (Hermit) on Jun 10, 2000 at 04:07 UTC | |
by Adam (Vicar) on Jun 10, 2000 at 22:31 UTC | |
by lhoward (Vicar) on Jun 11, 2000 at 02:28 UTC | |
by KM (Priest) on Jun 11, 2000 at 05:49 UTC |