I'm reading a book, Functional Programming Using F#, which says (page 33), in the section Declaration of higher-order functions
We have seen higher-order built-in functions like (+) and (<<)
and at the end of the section
Higher-order functions may alternatively be defined by supplying the arguments as follows in the let-declaration:
let weight ro s = ro * s ** 3.0;;
However there were some helpful comments at the bottom of a question that I asked earlier today (which was originally titled "When should I write my functions as higher order functions") that seem to throw some doubt on whether these examples are in fact higher-order functions.
The wikipedia definition of higher-order function is:
a higher-order function (also functional form, functional or functor) is a function that does at least one of the following: (i) take one or more functions as an input; (ii) output a function.
On the one hand, I can see that functions like (+)
, and weight
might be regarded as higher order functions because given a single argument they return a function. On the other hand I can see that they are properly regarded as curried functions. I'm learning F# as a self-study project and would like to get the concepts clear, so the answers and discussion on this site are particularly helpful.
My question is, what is the right term for these functions, and, perhaps more importantly, how do people normally use the terms "higher order functions" and "curried functions"?
weight
example,weight ro
returns afloat -> float
function so is technically a higher-order function. But it is more usual to call it a curried function, just as it is more usual to call my pet Fido a dog rather than a mammal. – TooTone