I'm getting completely stumped on writing a function makeIterate
that constructs an iterated structure out of a list of functions e.g. {f, g, h}
and a list of corresponding arguments {d1, d2, d3}
(same number of arguments).
More specifically, I would like the input
makeIterate[expr, {f, g, h}, {d1, d2, d3}, final]
have the following output
f[expr, {d1}, g[#, {d2}, h[#, {d3}, final] &] &]
The first function acts on expr
, taking d1
as the second argument. Each subsequent function is to be inserted into the third argument.
The problem I'm running into here is that since the functions {f, g, h}
themselves need to end up being inside a Function
in the output, I'm having trouble disentangling the pure Functions
that are supposed to be part of the output, and the Functions
that are meant to be used in makeIterate
.
Any suggestions?