3 ms·
I guess I'd be more interested in how this solution came to be, rather than a step by step of how to get there. What other methods did you try? What worked an
by jamesfe 11y ago
I guess I'd be more interested in how this solution came to be, rather than a step by step of how to get there. What other methods did you try? What worked and what didn't? How did you solve the problems you came across?
That being said - well written, very informative, and I very much appreciated the simple and concise definition of currying.
Thanks.
- kevincennis 11y agoHey. Thanks so much for the feedback. It's been a while since the first time I ever tried to do this, so it's a bit difficult to remember exactly what my initial approach was. But I definitely remember the moment where I realized I needed the `resolver` function. Initially, I think I tried to just make `curry` return something that looked like the anonymous function inside of `resolver` – which of course didn't work, because I had no way to store all of the previous arguments. Ultimately, I think there are probably a number of good ways to do this, and I would never claim that mine is the "right" one. It's really just a representation of the way I think about things, I guess. If you do a bit of digging, there are some other great blog posts about currying, and each one has a different approach. It's actually pretty interesting to see how different people have implemented it. For a what basically amounts to a 10-line function, there's a pretty amazing amount of diversity in the way people approach it.