Measures Concepts
GitHub icon

Function Composition

Function Composition - language feature

< >
Example from JavaScript, TypeScript:
function o(f, g) { return function(x) { return f(g(x)); } }
Example from C#:
// Call example: // var c = Compose(f, g); // // Func<int, bool> g = _ => ... // Func<bool, string> f = _ => ... Func<TIn, TOut> Compose<TIn, TMid, TOut>(Func<TMid, TOut> f, Func<TIn, TMid> g) => _ => f(g(_));
Example from Haskell:
foo = f . g
Example from APL:
foo←f∘g
Example from Coconut:
(f..g..h)(x, y, z)
Example from Raku:
my &foo = &f ∘ &g;
Example from fp:
/+∘α(bu + 1):<1,2,3,4,5,6,7,8,9,10>

Languages with Function Composition include JavaScript, C#, Haskell, TypeScript, APL, Coconut, Raku, fp

Languages without Function Composition include C3

This question asks: Can you pass functions into other functions and get new combined functions?

Read more about Function Composition on the web: 1.

HTML of this page generated by Features.ts

View source

- Build the next great programming language · Search · Add Language · Features · Creators · Resources · About · Blog · Acknowledgements · Queries · Stats · Sponsor · Day 605 · feedback@pldb.io · Logout