function velo_func(t)
if t < 1.5e-3
vx = 0.
vy = -50.
vz = 0.
else
vx = 50.
vy = 0.
vz = 0.
end
return (vx,vy,vz)
end
data = Dict()
data["total_time"] = dtime#Tf
data["time"] = 0.
data["dt"] = dtime
data["friction"] = fric
data["rigid_body_velo"] = Array{Tuple{Int64,Function},1}([(1,velo_func)])
function f(data)
rigid_solids = data["rigid_body_velo"]::Array{Tuple{Int64,Function},1}
for (s,f) in rigid_solids
solid = solids[s]
vex,vey,vez = f(t)
end
end
My problem is (vex, vey,vez) is recognised as Tuple(Any,ANy,Any).
Could u please help me how to make Julia knows it is Tuple(Float,Float,Float)?
Firstly, you are using the same name, f, for both the outer function and the function retrieved from the Dict. I’m not sure if that causes any problems, but it’s confusing and not a good idea, imho.
Secondly, Julia doesn’t know which function is coming out of your Dict. It just knows it’s some function, any function, and therefore it cannot predict what the types of the outputs will be. It doesn’t matter that you name the outputs vex, vey, vez, there’s no way to know that they have anything to do with the function velo_func.
Will data["rigid_body_velo"] contain many functions or just one?