[Xerte] Re: sum part of array?

Pat Lockley patrick.lockley at googlemail.com
Tue Jul 26 15:29:49 BST 2011


eval(array.join("+")) ?

On Tue, Jul 26, 2011 at 2:50 PM, Dave Burnett <d_b_burnett at hotmail.com> wrote:
>
>
> Just out of curiosity, is there any way to sum part of an array?
>
>
> [1,2,3,4,5]
>
>
> Lets say I have an index variable and I always will want to sum from 0 to
> that variable.
>
>
> pseudo
> my_array.sum(0,var);
>
>
> Or am I forced to loop + add?
>
>
> Or any elegant way to create a temp array of the target elements and sum on
> that instead?
>
>
> Dave
>
>
>
>
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it. Please do not
> use, copy or disclose the information contained in this message or in any
> attachment. Any views or opinions expressed by the author of this email do
> not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
> _______________________________________________
> Xerte mailing list
> Xerte at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it.   Please do not
> use, copy or disclose the information contained in this message or in any
> attachment.  Any views or opinions expressed by the author of this email do
> not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
>
>



More information about the Xerte mailing list