I am trying to build a two element array in Julia, where each sub-array has a different type (one is a vector of Int64
s, the other is an array of Float32
s).
The code belows automatically converts the element that I want to be an Int64
into a Float32
, which is what I don't want:
my_multitype_array = [ collect(1:5), rand(Float32,3) ]
The resulting array automatically converts the Int64
s in the first array (defined via collect(1:5)
) into a Float32
, and the resulting my_multitype_array
has type 2-element Array{Array{Float32,1}}
. How do I force it to make the first sub-array remain Int64
s? Do I need to perhaps pre-define my_multitype_array
to be an empty array with two elements of the desired types, before filling it out with values?
And finally, once I do have the desired array with different types, how would I refer to it, when pre-stating its type in a function? See below for what I mean:
function foo_function(first_scalar_arg::Float32, multiple_array_arg::Array{Array{Float32,1}})
# do stuff
return
end
Instead of ::Array{Array{Float32,1}}
, would I write ::Array{Array{Any,1}}
or something?