Skip to content

Conversation

@lanathlor
Copy link

Hello.
This commit introduces a set of CurryN functions to transform standard multi-argument functions into curried form. Each CurryN takes a function with N parameters and returns a nested chain of unary functions that can be called one argument at a time.

Example:
Curry3(func(x, y, z int) int { return x + y + z }) → func(int) func(int) func(int) int

These utilities follow the functional programming style established in the library and can be found on other TS libs like lodash or ramda.

Here we are limited by go and we need to implement it manually for all arity (or at least i didnt found a workaround)

Added Curry(2..5) functions to allow partial application of functions with multiple arguments.
@BetaMedina
Copy link

Hello, I’d like to share my thoughts here. The approach taken has some flaws that could be problematic. Don’t you find it strange to have to implement repeated methods just to make your functionality work?
How would it behave if I wanted a Curry10, for example?

From my perspective, the fact that methods need to be repeated starts to become an issue…

Couldn’t using Any or perhaps an approach with Reflect make it more agnostic?

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