All this currying and partial application stuff is all very interesting, but surely its has to have some kind of run-time performance hit. What if I just want to keep things straightforward?
Firstly, if we have a function that takes only a single argument, there is nothing to curry. It makes no sense to call a function with no arguments, so your only option is to make the exact call.
That in mind, we can do this:
let repeat(str, n) = ...
That syntax is sure to catch out C# programmers (like me), because it looks a lot like a normal C# function call. You might not even register, at first glance, the extra parenthesis around the arguments. However, these parenthesis are nothing to do with the function syntax, but everything to do with tuples:
let name = ("Fred", "Smith")
here, name is equal to the pair of values “Fred” and “Smith”. Tuples can have more than 2 components. The type is reported as:
val x : string * string
Personally, I find that * as the separator a bit jarring, but I assume there is a good reason to use it in preference to “,” - maybe it will come to light some day.
Anyway, a tuple is a simple data structure that allows you to group 2 or more components into a single argument, and thereby create functions that need not be curried.