Currying (not vindaloo)

Dustin Campbell has just posted an article title ”The Art of Currying“ that has taken me right back to my Haskell/functioning programming days in first year University. Currying is when you take a function with multiple arguments and transform it into a function that takes a single argument and returns another function for any additional arguments.

To steal Dustin’s example, add(5, 10) becomes add(5)(10). The benefit of this is that you can define functions in terms of other functions (using a related technique called “partial application” – I start to get lost here as my memory starts to fail me).

Dustin’s article gives a great overview with code examples to explain the concept.

Comments