In object-oriented languages, if I had a bunch of functions that all required the same set of parameters, I would create a helper class and have the functions be methods for that class.
In julia, I have an NCDataset and a set of functions that do something with the value in the dataset at a given variable, X, Y, Z, and T.
struct Helper
var::String
x::Int64
y::Int64
z::Int64
t::Int64
end
function do_thing_1(helper::Helper, ds::NCDataset)
return ds[helper.var][[helper.x,helper.y,helper.z,helper.t]*2
end
function do_thing_2(helper::Helper, ds::NCDataset)
return ds[helper.var][[helper.x,helper.y,helper.z,helper.t]/2.0
end
However this is kind of verbose. Is there a way to do this so that the functions share state variables that are initialized somehwere? Or is that not a paradigm in multiple-dispatch languages?