Skip to content

Conversation

UtpalKant
Copy link
Contributor

made the partial execution/currying easy

made the partial execution/currying easy
if(ip.length < func.length) {
return curry.bind(this, ...ip);
}
return func(...ip);
Copy link
Owner

@sadanandpai sadanandpai Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this not be func.apply(this, ip);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this function isn't called over any object and thus there is no requirement of holding the context (of this ref).

Copy link
Owner

@sadanandpai sadanandpai Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let sum = curryFunc(function () {
    console.log(this)
});

sum.call(1);

I can see this fails without the proper implementation of this

};
function curryFunc(func) {
return function curry(...ip) {
if(ip.length < func.length) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep the func as fn and ip as args for consistency

@UtpalKant UtpalKant requested a review from sadanandpai June 27, 2024 07:14
@sadanandpai sadanandpai merged commit a459987 into sadanandpai:main Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants