I can identify the input and output variable names of the functions. Using this information, I want to combine these functions to construct a composite function. I hope to obtain the result with the specified variable names without inputting intermediate data. The code is as follows:
I can identify the input and output variable names of the functions. Using this information, I want to combine these functions to construct a composite function f(x,y) that can obtain the result for z4 without inputting intermediate data.
Is func_infos some data you’re given and must work with, or is it just your version of piping syntax? The base |> is only useful for single inputs and outputs, but Pipe.jl uses a macro to make multiple inputs and outputs work. Not sure if inputs could jump to multiple steps like :z1 to :f2 and :f4, though. func_infos could also just be rewritten as temporary variables and function calls, so am I correct in assuming func_infos is intended to be mutated?
But this is just an example function. When encountering other similar functions, I can’t manually combine each one. I’m wondering if there’s a general method to combine the above functions.
It’s possible to compose functions without resorting to metaprogramming. Perhaps try with CallableExpressions.jl, some other packages are available, too.
if that is the function composition you want? That is, why are you defining a custom function-composition representation using a Dict of symbols rather than using the Julia language itself?
If I’m reading the docs correctly, CallableExpressions doesn’t introduce more named types like anonymous functions do, right? Not sure if expression_into_type_domain does that. My concern here is that named types persist so a program that evaluates, uses, and discards an arbitrary number of anonymous functions is a big memory leak. I wasn’t even sure of that but I started another thread to check.
This might differ slightly from the initial approach. Here, I defined various intermediate variables within the function. By defining the outputs of multiple functions, I can use the intermediate outputs as inputs for other functions. This way, my problem is solved. However, this approach relies on the order of function calculations, so it may be worth considering constructing a computational graph to determine the sequence.