Here is the big surprise. In Haskell, every function has only
one argument. You should be rising up to call me a liar at
this point.
Haskell has a function named "take" that extracts the first
N items in a list and spit them out in a new list.
It looks something like this:
take 5 listHere the function "take" clearly has 2 arguments.
The function "take" is applied to the next argument "5" to produce an intermediate (invisible) function that in turn takes just one argument (the list). How about that? Haskell always does this.
We can actually tap into this process and grab that intermediate function. Doing so is called "partial application". Consider this:
takefive = take 5Now we have a specific function that takes the first 5 things from a list and gives them to us in a new list.
Tom's software pages / tom@mmto.org