If I want to apply f
first and g
second, I have to write:
g . f
Is there another standard syntax that would allow me to write the functions in the reverse order?
f <whatever> g
I know I can just invent my own syntax:
compose f g x = g (f x)
and then use it like this:
f `compose` g
But I would rather use a standard library facility.
The inverse composition rulef ( g ( x ) ) = x f(g(x))=x f(g(x))=xf, left parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis, equals, x for all x in the domain of g.
The composition operator (○) indicates that we should substitute one function into another. In other words, (f○g)(x)=f(g(x)) indicates that we substitute g(x) into f(x). If two functions are inverses, then each will reverse the effect of the other.
The composition of two functions g and f is the new function we get by performing f first, and then performing g. For example, if we let f be the function given by f(x) = x2 and let g be the function given by g(x) = x + 3, then the composition of g with f is called gf and is worked out as gf(x) = g(f(x)) .
In Maths, the composition of a function is an operation where two functions say f and g generate a new function say h in such a way that h(x) = g(f(x)). It means here function g is applied to the function of x. So, basically, a function is applied to the result of another function.
f >>> g
from Control.Arrow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With