by yummyfajitas · 15y ago · 0 comments
Either you misunderstood, or the people using them misunderstood.
Lambdas are anonymous functions. In javascript terminology:
_.map(someNumbers, function (x) { return x +1; } /* <- lambda */)
Closures are a way of hiding state (or at least data) in anonymous functions: makeCounter() {
var x = 0;
function numCalls() { return x++; }; <---the variable x is "closed over"
return numCalls;
}
Monads are a method of encapsulation, with goals similar to object orientation. OO is about hiding data inside objects, whereas monads are about hiding most of the outside world from your functions. var c = 2;
var f = function (x) { return (2 * x); };
var g = function (h, x) { return h(x); };