Nov 13
Function Composition in Haskell
Function Composition:
In haskell, it's defined as:
As you can see, there is a lambda in the definition. An obvious use for function composition then is for the map function. Often there are times when you need to apply two functions for every element in a list, and this is pretty much made for that occasion.
It also has a simpler use: getting rid of that jungle of parenthesis. These two are identical:
The only reason that function composition can be implemented (and in such a beautiful way) is through high-order functions. They are the life and soul of Haskell. For those of you that don't know; a high-order function is any function that passes a function as an argument and/or returns function.
One sign that I may be embracing Haskell a little too much: I'm beginning to think being lazy isn't a bad thing.
Filed under //
haskell

