juliafunction-composition

Is there an operator for function composition in Julia?


Say I have two functions:

f(x) = x^2
g(x) = x + 2

Their composition is the function

h(x) = f(g(x))

Is there an operator for function composition in Julia? For example, if * was an operator for function composition (which it isn't), we could write:

h = f * g

P.S. I know I can define it if I want to,

*(f::Function, g::Function) = x -> f(g(x))

Just asking if there is an operator form already in Julia.


Solution

  • Coming here later. āˆ˜ is available by default