> 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.
>>