Comments (13)
from functional-programming-jargon.
Here's a whack at it:
Functional Combinator
A higher-order function, usually curried, which returns a new function changed in some way. Functional combinators are often used in point-free programming to write especially terse programs.
from functional-programming-jargon.
You know what you'd like it to say?
from functional-programming-jargon.
Are you referring to Fixed-point combinator?
from functional-programming-jargon.
from functional-programming-jargon.
Most known fixed-point combinator is Y combinator, but it will not work in JS, because of order of evaluation. So there is Z combinator to the rescue
// The Y combinator is defined as:
// Y = λf.(λx.f (x x))(λx.f (x x))
// The Z combinator is defined as:
// Z = λf.(λx.f (λv.((x x) v))) (λx.f (λv.((x x) v)))
const Z = f => (x => f (v => ((x (x)) (v)))) (x => f (v => ((x (x)) (v))))
// example of usage: factorial
const factgen = fact => n => n < 2 ? 1 : n * fact(n-1)
const fact = Z(factgen)
Fixed-point combinator is a function to find fixed point of other function. Simple example of fixed point of function is dotty number e.g. solution of cos(x) = x
.
But the most striking thing about fixed-point combinator if it is applied to higher order function e.g. function which returns function, fixed point of higher order function is function too. First time I realized it blowed my mind.
from functional-programming-jargon.
Other idea: we can expand Lambda Calculus
section.
A lot of simple Lambda Calculus
ideas pretty trivial to demonstrate in JS
//True = λt.λf.t
//False = λt.λf.f
//Not = λb.b False True
const True = t => f => t
const False = t => f => f
const Not = b => b (False) (True)
const toBool = (churchBoolean) => churchBoolean (true) (false)
//Zero = λf.λx.x
//Succ = λn.λf.λx.f (n f x)
const Zero = f => z => z
const Succ = n => f => z => f (n (f) (z))
const toNumber = (churchNumeral) => churchNumeral((x) => x+1) (0)
But I suppose it can be separate page dedicated to Lambda Calculus.
from functional-programming-jargon.
from functional-programming-jargon.
It would be nice to see definition of various combinations. The C combinator is rather practical and can be used in everyday coding.
from functional-programming-jargon.
from functional-programming-jargon.
@jethrolarson Don't sure that i get your question right. Yes C combinator is type of curing.
My knowledge of combinators is rather limited, actually i get it from this great talk of Reginald Braithwaite https://youtu.be/3t75HPU2c44
from functional-programming-jargon.
I think if we have functional combinators in the doc we should just have a general definition and not try to teach the details of every combinator. We can link out for that.
from functional-programming-jargon.
Also worth to elaborate a bit more, about why Y combinator does not work. It is because order of evaluation and add link to Lazy evaluation
section
from functional-programming-jargon.
Related Issues (20)
- Add a section on higher-kinded types HOT 2
- Explanation of `lens` HOT 2
- TOC refers to absent anchor tags HOT 2
- Idempotent inaccurate HOT 2
- Volunteering - Polish translation HOT 4
- Closure appears twice in the document HOT 2
- Avoid polluting globals HOT 2
- Add memoization HOT 1
- Add Identity Function
- Category, Functor, Monad, Comonad, etc. should mention algebraic laws HOT 1
- Natural transformations HOT 1
- Functors are maps for categories HOT 3
- Category example is a preorder/partial order HOT 1
- Suggestions from HN HOT 1
- Add Total Functions HOT 1
- Organize for extensibility HOT 3
- Functor example does not make any sense HOT 2
- Explain why HOT 1
- Monad chain does exist now in JS HOT 3
- Is array concatenation a monoid?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from functional-programming-jargon.