Re: Sum and other algorithm functions

2015-09-10 Thread anonymous via Digitalmars-d-learn
On Thursday 10 September 2015 15:48, Namal wrote: > Hello, > > how can I define the range for the sum function which I want to > sum up? For instance how do I sum up the first 3 elements of an > array > > int[] a = [1,2,3,4,5,6,7,8,9]; > > or the last 3? First you slice the first/last 3,

Re: Sum and other algorithm functions

2015-09-10 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 10 September 2015 at 13:48:16 UTC, Namal wrote: Hello, how can I define the range for the sum function which I want to sum up? For instance how do I sum up the first 3 elements of an array int[] a = [1,2,3,4,5,6,7,8,9]; or the last 3? In this case, you can simply slice array

Sum and other algorithm functions

2015-09-10 Thread Namal via Digitalmars-d-learn
Hello, how can I define the range for the sum function which I want to sum up? For instance how do I sum up the first 3 elements of an array int[] a = [1,2,3,4,5,6,7,8,9]; or the last 3?