What's special about currying or partial application?
Posted
by
Vigneshwaran
on Programmers
See other posts from Programmers
or by Vigneshwaran
Published on 2012-11-27T12:17:35Z
Indexed on
2012/11/27
17:19 UTC
Read the original article
Hit count: 369
I've been reading articles on Functional programming everyday and been trying to apply some practices as much as possible. But I don't understand what is unique in currying or partial application.
Take this Groovy code as an example:
def mul = { a, b -> a * b }
def tripler1 = mul.curry(3)
def tripler2 = { mul(3, it) }
I do not understand what is the difference between tripler1
and tripler2
. Aren't they both the same? The 'currying' is supported in pure or partial functional languages like Groovy, Scala, Haskell etc. But I can do the same thing (left-curry, right-curry, n-curry or partial application) by simply creating another named or anonymous function or closure that will forward the parameters to the original function (like tripler2
) in most languages (even C.)
Am I missing something here? There are places where I can use currying and partial application in my Grails application but I am hesitating to do so because I'm asking myself "How's that different?"
Please enlighten me.
© Programmers or respective owner