4 ms·
"JavaScript doesn’t include this out of the box, but it’s an interesting exercise to write your own." I may be misunderstanding point-free notation (I had neve
by freefal67 9y ago
"JavaScript doesn’t include this out of the box, but it’s an interesting exercise to write your own."
I may be misunderstanding point-free notation (I had never heard of it before), but I think `bind` (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...) let's a programmer provide some of the arguments to a function and returns a new function that requires only the remaining arguments.
- beaconstudios 9y agobind provides partial application but doesn't directly help towards point-free notation.
- Too 9y agoIt's also easy to implement as a one liner var atleastTwo = function(x){return function(){return Math.max(2,x);} Even simpler with typescript var atLeastTwo = (x) => (() => Math.max(2, x))
- WalterSear 9y agoES6 const atLeastTwo = x => Math.max(2,x)
- leshow 9y agohis is a function that returns a function, i.e. you'd need to call atLeastTwo(x)(); to get a result, yours is just a function. in es6 the equivalent thing to what he wrote would be: const atLeastTwo = x => () => Math.max(2, x);
- deleted 9y ago[deleted]