[Haskell-cafe] Curried function terminology
nowgate at yahoo.com
Mon Oct 5 00:18:56 EDT 2009
This is from Learn You A Haskell:
Every function in Haskell officially only takes one parameter. So how is it possible that we defined and used several functions that take more than one parameter so far? Well, it's a clever trick! All the functions that accepted several parameters so far have been curried functions. What does that mean? You'll understand it best on an example. Let's take our good friend, the max function. It looks like it takes two parameters and returns the one that's bigger. Doing max 4 5 first creates a function that takes a parameter and returns either 4 or that parameter, depending on which is bigger. Then, 5 IS APPLIED TO THAT FUNCTION and that function produces our desired result.
What really happens when we do multThree 3 5 9 or ((multThree 3) 5) 9? First, 3 is applied to multThree, because they're separated by a space. That creates a function that takes one parameter and returns a function. So then 5 IS APPLIED TO THAT, which creates a function that will take a parameter and multiply it by 15. 9 IS APPLIED TO THAT FUNCTION and the result is 135 or something."
The language (in CAPS) in the above two paragraphs seems to be backwards. In the first paragraph, since functions are conventionally "applied" to parameters shouldn't it read something like THE PARTIALLY APPLIED FUNCTION IS THEN APPLIED TO the 5? Or is the terminology different for Haskell, as opposed to say, Scheme or just about any other language?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe