Changes

Jump to navigation Jump to search
1,093 bytes added ,  22:18, 6 March 2024
Line 4: Line 4:     
For more details, please go through [[Combinators Theory]].
 
For more details, please go through [[Combinators Theory]].
 +
 +
Functional Languages often use patterns to combine function. These are called Combinators. For example, few of these patterns are given in [https://thecodest.co/blog/power-of-functional-programming-in-javascript-part-2-combinators/ Functional programming in JavaScript Part 2 - Combinators] (such as Tap, Currying, Pipe/Compose, Fork, Alternation, Sequence, etc.).
 +
 +
In z^3, Combinators are accessible as a part of an array of functions, as well as in the Global Scope.
 +
 +
Take for example the B combinator, which is defined as B = a => b => c => a(b(c)), and takes functions and apply them one atop the other.
 +
 +
In z^3, [SUM,RECIPROCAL].$combinators("B") gives a function that can be called with arguments.
 +
 +
[SUM,RECIPROCAL].$combinators("B")(1..10)
 +
 +
gives 2.9289682539682538 (which is SUM(RECIPROCAL(1..10))).
 +
 +
From the Global Scope, the call could be λB([SUM,RECIPROCAL])(1..10) . All combinators are named such as λCOMBINATOR with a λ prefix at the global scope. The parameters are an array of functions, and the resulting function can be used later with parameters to provide results.
2,824

edits

Navigation menu