Posts

Showing posts from July, 2014

Currying and Closures

Just a quick one Closures might be well known amongst many C# practitioners - apart from  me it seems. I read about them ages ago and then haven't knowingly applied them.  Of course, I have been using them  (or at least a variation on the theme) often in C# by virtue of using 'lambdas in lambdas' when using LINQ for example, and lambdas which refer to variables in the method in which they are created.  I mentioned functional programming including Currying in the last post, and this is still my current focus, its satisfying my ADHD for the time being.   Anyway, It turns out that if you want a bit of a better understanding of how Currying works,  then understanding closures can help you  take a leap of faith.  Currying in Haskell The following example is taken from Learn you a Haskell The function multiplies 3 numbers together and returns the result. The  first line defines a function, multThree,  which can be read as  taking 3 arguments and returning a valu