I think something like this
function one_func(x)
# x nees to be iterable of bool
return function(x1::AbstractVector)
res = 1
for (i, doit) in enumerate(x)
if doit
res += 2x1[i]^2
end
end
res
end
end
function func_factory(len)
seed = ((false, true) for i in 1:len)
collect(one_func(x) for x in Iterators.drop(Iterators.product(seed...),1))
end
funs = func_factory(2)
funs[1]([1, 2])
funs[2]([1, 2])
funs[3]([1, 2])
funs6 = func_factory(6)
[fun([1,2, 3, 4, 5, 6]) for fun in funs6]
You can also use macros for even better results. For this is sufficient for me.