[Xerte] Re: sum part of array?

Julian Tenney Julian.Tenney at nottingham.ac.uk
Tue Jul 26 16:14:16 BST 2011


The first n numbers, or the numbers between n and m?

From: xerte-bounces at lists.nottingham.ac.uk [mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Dave Burnett
Sent: 26 July 2011 16:12
To: Xerte list
Subject: [Xerte] Re: sum part of array?



Legpuller.


Besides using the evil eval, how does it limit the indexes it acts on?





> Date: Tue, 26 Jul 2011 15:29:49 +0100
> From: patrick.lockley at googlemail.com
> To: xerte at lists.nottingham.ac.uk
> Subject: [Xerte] Re: sum part of array?
>
> 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.
> >
> >
> >
>
> _______________________________________________
> Xerte mailing list
> Xerte at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20110726/e619b7dc/attachment-0001.html>


More information about the Xerte mailing list