Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

RE: Answer: How can I add all the numbers in an array with out doing a foreach loop?

by Adam (Vicar)
on Jun 09, 2000 at 23:43 UTC ( [id://17414]=note: print w/replies, xml ) Need Help??


in reply to Re: 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?

Your first answer is really a foreach loop. Remember that for and foreach are synonyms. Your second answer, however, is very slick! Nice.
  • Comment on RE: Answer: How can I add all the numbers in an array with out doing a foreach loop?

Replies are listed 'Best First'.
RE: RE: Answer: How can I add all the numbers in an array with out doing a foreach loop?
by KM (Priest) on Jun 09, 2000 at 23:45 UTC
    Hence me saying 'The loopish way..'. Actually, they are both loops. I believe internally join() still loops to actually join all the elements. It isn't a loop like a for or foreach.

    Cheers,
    KM

      Right, I was just pointing out that using 'for' doesn't answer the question of not using a 'foreach' loop. It looks kind of funny when the question stipulates that the person doesn't want to use something, and then you use it in your answer. Thats all.
        I gave two ways to do it. There is no way to do it without some sort of loop happening somewhere. It is also why I said that that is the loopish way. Sorry if I gave too much information for your taste. I see your answer.. oh wait.. you didn't have an answer.

        Cheers,
        KM

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found