Skip to content

Commit

Permalink
simplify code using where syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
houtanb committed Jul 24, 2017
1 parent e763c78 commit 3e8fdad
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions tests/julia_derivative_test/preprocessor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,34 +85,10 @@ function run_preprocessor(modfile::String)
return jsonout
end

function get_vars!(d::Array{DynareModel.Endo,1}, json::Array{Any,1})
function get_vars!(d::Array{T,1}, json::Array{Any,1}) where {T <: DynareModel.Atom}
idx = 1
for i in json
d[idx] = DynareModel.Endo(i["name"]::String, i["texName"]::String, i["longName"]::String)
idx += 1
end
end

function get_vars!(d::Array{DynareModel.Exo,1}, json::Array{Any,1})
idx = 1
for i in json
d[idx] = DynareModel.Exo(i["name"]::String, i["texName"]::String, i["longName"]::String)
idx += 1
end
end

function get_vars!(d::Array{DynareModel.Param,1}, json::Array{Any,1})
idx = 1
for i in json
d[idx] = DynareModel.Param(i["name"]::String, i["texName"]::String, i["longName"]::String)
idx += 1
end
end

function get_vars!(d::Array{DynareModel.ExoDet,1}, json::Array{Any,1})
idx = 1
for i in json
d[idx] = DynareModel.ExoDet(i["name"]::String, i["texName"]::String, i["longName"]::String)
d[idx] = T(i["name"]::String, i["texName"]::String, i["longName"]::String)
idx += 1
end
end
Expand Down

0 comments on commit 3e8fdad

Please sign in to comment.