Any tools for making expressions composed functions from nested function calls?

In a macro, I’m trying to turn the expression f(g(x)) into (f ∘ g)(x).

To make sure I’m not trying to re-invent the wheel, I figured I would ask here if anyone has written a macro which does this.

The tricky case is probably something like:

(x -> x)((x -> x)(x))


((x -> x) ∘ (x -> x))(x)

(of course likely with a more complex body.)

But if you want to restrict yourself to cases where f and g are Symbols this should be a one-liner in a macro I think.

Yeah. I think we can restrict ourselves to scenarios where f and g are symbols. It should be easy.

1 Like