I am having difficulty trying to write a macro that takes a vector of types, defines 3 input parameters for the constructor of each type, loops over different values of the parameters and instantiates the types inside of the loop. Consider this pseudo-code:
using Plots, Interact macro loop_ctor(types) quote for i=1:length($types) # define variables ai, bi, ci for the ith type end # write a for loop with all variables defined above @manipulate for a1=1:10, b1=1:10, c1=1:10, a2=1:10, b2=1:10, c2=1:10, ... # instantiate the types obj1 = types(a1, b1, c1) obj2 = types(a2, b2, c2) ... # compose with some container type objs = MyType(obj1, obj2, ...) # plot with Plots.jl plot(objs) end end end end
I am very new to macros and couldn’t progress much after reading the documentation online. Could someone give me a hand?