Re: Merging Multiple Array elements



Pradeep Patra <smilesonisamal@xxxxxxxxx> wrote:

The reason I need this requirement because I have something as
follows:

@array1 = returned by func1(i=0); [NOTE: this is just for illustration
not actual code]
@array2 = returned by func1(i=1);

I cannot change the func1(i); So I have to summing all the sub arrays
returned by func1(i) itself.

Any suggestions how to go about this?

Yes, several:
- If you really want to collect the individual return results before
summing them up then use an array of (references to) arrays as explained
before.
- with each iteration (i=0, i=1, ...) don't store the return result, but
add it to your grand total right away
- and last but not least: please post actual Perl code, not some
pseudo-code

jue
.



Relevant Pages

  • Re: trouble creating array of objects
    ... >1 reason he might not want to use vectors is perhaps because he isn't ready ... >Or perhaps he is simply learning about Arrays. ... there is a learning curve to telling newbie's to ... Comeau C/C++ with Dinkumware's Libraries... ...
    (alt.comp.lang.learn.c-cpp)
  • Re: trouble creating array of objects
    ... >>1 reason he might not want to use vectors is perhaps because he isn't ... >>Or perhaps he is simply learning about Arrays. ... A programmer should at least know and understand templates before they use ...
    (alt.comp.lang.learn.c-cpp)
  • Re: [PATCH 1/2] avoid OPEN_MAX in SCM_MAX_FD
    ... In git, I used PATH_MAX, and the reason ... I want a constant for arrays ... to some paper standard". ... realize that modern distributions don't put the kernel headers in their ...
    (Linux-Kernel)
  • Re: trouble creating array of objects
    ... > about dynamically multidimensinoal arrays is described. ... it's an excellent learning excercise. ... This is called the C++ standard template library and it is an addition to ... >> Another reason might be the overheads incurred. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Convert Arrays into hashes
    ... How can i convert both of these arrays into %hash, ... but in practice if @array2 held literally numbers from 0 ... Also you should always use warnings and strict to catch errors. ...
    (perl.beginners)