Hi Chris,
Unfortunately I don't know why the type changes from Array{Array{Int64,1},1}
to Array{Any,1}. But I have a suggestion to what you can do to keep it as
Array{Array{Int64,1},1}.
My initial shot would be to do a + [[1,1] for i = 1:5] instead of a + 1:
julia> a + [[1,1] for i = 1:5]
5-element Array{Array{Int64,1},1}:
[2,2]
[2,2]
[2,2]
[2,2]
[2,2]
Or, if you want to simplify the way you do it, just define a function like
this:
julia> function newsum(a::Array{Array{Int64,1},1}, i::Int)
lengtha = size(a,1);
return([[i,i] for i = 1:lengtha])
end
newsum (generic function with 1 method)
julia> newsum(a,1)
5-element Array{Array{Int64,1},1}:
[1,1]
[2,2]
[3,3]
[4,4]
[5,5]
But I am sure you will find many more suggestions here! ;)
Best,
Charles
On 5 December 2015 at 02:16, Chris <[email protected]> wrote:
> I am confused about the following:
>
> julia> a = [[1,1] for i = 1:5]
> 5-element Array{Array{Int64,1},1}:
> [1,1]
> [1,1]
> [1,1]
> [1,1]
> [1,1]
>
> julia> a + 1
> 5-element Array{Any,1}:
> [2,2]
> [2,2]
> [2,2]
> [2,2]
> [2,2]
>
> Specifically, why does the type change from Array{Array{Int64,1},1} to
> Array{Any,1}, and what can I do to keep it as Array{Array{Int64,1},1}?
>
> Thanks,
> Chris
>
--
Um axé! :)
--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles