> Hi
> Mauro - thanks for that as that makes it clear whats happening under the 
> bonnet. So, what if you then wanted to sum...
> 1.4827   
>  1.48069 
>  0.884897 
>  1.22739 
> .... is that possible or am I being a bit dumb here.

Just add another sum(ans) after below two statements, that then sums the 
>> 4-element Array{Float64,1}: 
>>  1.4827   
>>  1.48069 
>>  0.884897 
>>  1.22739 

> On Thursday, 12 March 2015 10:59:34 UTC, Mauro wrote:
>>
>> > Can I still sum? 
>>
>>
>> Maybe it's clearer like this: 
>> julia> [ x[i-4:i-1] for i = [6,7,8]] 
>> 3-element Array{Array{Float64,1},1}: 
>>  [0.392471,0.775959,0.314272,0.390463] 
>>  [0.775959,0.314272,0.390463,0.180162] 
>>  [0.314272,0.390463,0.180162,0.656762] 
>>
>> julia> sum(ans) 
>> 4-element Array{Float64,1}: 
>>  1.4827   
>>  1.48069 
>>  0.884897 
>>  1.22739 
>>
>> So 1.4827 = ans[1][1]+ans[2][1]+ans[3][1] 
>>
>> > On Thursday, 12 March 2015 09:50:19 UTC, Mauro wrote: 
>> >> 
>> >> > const x = rand(8) 
>> >> > [ x[i-4:i-1] for i = 6] .. this gives me a 4 element array. 
>> >> 
>> >> This seems a bit odd, what are you trying to achieve here?  Anyway it 
>> >> produces a Array{Array{Float64,1},1}, i.e. an array of arrays 
>> containing 
>> >> one array. 
>> >> 
>> >> > I now want to sum the ouput - this is what I tried ... 
>> >> > sum([ x[i-4:i-1] for i = 6]) ... what am I doing wrong? 
>> >> 
>> >> This sums all first elements, second elements, etc.  As there is only 
>> on 
>> >> array in the array, it doesn't do all that much. 
>> >> 
>>
>>

Reply via email to