Open vijayksingh opened 5 years ago
1) Purity :- Purity for a function is defined as one that will always return the same output for the same input and perform no side effects.
2) Side effects:- The change in the function due to any change outside that function is a side effect.
3) Idempotent:- i dont understand it completely but i have read about it , it goes something like this , it is a property of some operations such that no matter how many times you execute them, you achieve the same result. i will try to understand it better with more examples.
4) Point Free style:- The definition according to wikipedia is , Tacit programming (point-free programming) is a programming paradigm in which a function definition does not include information regarding its arguments, using combinators and function composition [...] instead of variables.
i ve got some good answers on stack overflow to understand it .
//not pointfree cause we receive args
var initials = function(name) {
return name.split(' ').map(compose(toUpperCase, head)).join('. ');
};
const compose = (...fns) => (...args) => fns.reduceRight((res, fn) => [fn.call(null, ...res)], args)[0];
const join = m => m.join();
//pointfree
var initials = compose(join('. '), map(compose(toUpperCase, head)), split(' '));
initials("hunter stockton thompson");
// 'H. S. T'
read good answers from here , https://stackoverflow.com/questions/944446/what-is-point-free-style-in-functional-programming
5) Dot chaining :- Call the functions one after the another using dot operators like a chain of functions is dot chaining.
$('someSelector'). oneFunction(). someOtherFunction(). someMoreOtherFunction();
Describe the following terminologies