0

I am new to Function Programming.

Expectation: Have Multiple functions using compose. Pass two parameter in compose and in 1st function check two parameter are equal. 2nd function has two argument 1st function return and another argument

Scenario 1:

const _ = require("lodash-fp");

const checkParmeter = (arg1, arg2) => {
  console.log(arg1);
  console.log(arg2);
};

_.compose(checkParmeter("argument2"), _.isEqual)(1, 1);

Above code returning Expected a function

Scenario 2:

When i wrap checkParamter function in curry it works

const _ = require("lodash-fp");

const checkParmeter = _.curry((arg1, arg2) => {
  console.log(arg1);
  console.log(arg2);
});

_.compose(checkParmeter("argument2"), _.isEqual)(1, 1);

According to scenario 1 before 1st function returns 2nd function executed which caused error whether i am right?

Can anyone brief the code. how it behaves

Rocket55
  • 157
  • 1
  • 9
  • The duplicate is about `_.flow` (left-to-right composition), but the answer still applies to `_.compose` (right-to-left composition) – Mulan Feb 20 '18 at 17:49
  • Another possible duplicate: [How to compose functions of varying arity using Lodash flow?](https://stackoverflow.com/questions/42161969/how-to-compose-functions-of-varying-arity-using-lodash-flow/42166494#42166494) – Mulan Feb 20 '18 at 17:52

0 Answers0