Re:When Does Point-Free Notation Make Code More Readable?
by Too on Friday September 29, 2017 @11:08AM
(#15365942)
It'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))
Re:When Does Point-Free Notation Make Code More Readable?
by WalterSear on Friday September 29, 2017 @11:21AM
(#15366057)
ES6
const atLeastTwo = x => Math.max(2,x)
Re:When Does Point-Free Notation Make Code More Readable?
by leshow on Friday September 29, 2017 @12:44PM
(#15366847)
his 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);
Re:When Does Point-Free Notation Make Code More Readable?
by beaconstudios on Friday September 29, 2017 @10:51AM
(#15365779)
bind provides partial application but doesn't directly help towards point-free notation.
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/Refe...) let's a programmer provide some of the arguments to a function and returns a new function that requires only the remaining arguments.