ThatGuyDuncan (68) [Avatar] Offline
11    Building composable functions
In fact, you can already do pretty much what the sort of things you’d do with methods in C# / VB .NET.

11.2   Partial function application
Partially applied functions are one of the most powerful parts of the function system in F# compared to C#, and opens up all sorts of interesting possibilities for working with functions. {mixing singular and plural}
Let’s start by clarifying something you’ll have observed already: what is the difference between the following two functions that appear to do the same thing, except that one uses brackets and commas for input arguments (like C#) and one doesn’t. {starts as a statement, seems to become a question, ends as a statement}

F# actually considers all the arguments as a single tuple – hence why the signature looks just like a tuple signature – that’s exactly what it is.

Partial application and currying
You might have heard of the terms “curried functions” and “partially applied functions” before.

11.3.1   Constraining functions
You probably use methods like this all the time when you wish to make functions easier to call when e.g. a subset of the arguments {are?} often the same.

11.3.2   Pipelines
"Take the last argument from a function call, and flip it over to the left-hand side of the pipe"
{in the example given, the function resides on the RIGHT side of the expression. However, this is not the first time I have seen this explained "backwards", so perhaps I'm missing something that's obvious to the better-educated. Can you possibly clarify?}

"Note that we could have even placed the unit argument for GetCurrentDirectory - () – at the head of the pipeline, but in this case, I’ve left it in place."
{expecting "GetCurrentDirectory()" instead of "GetCurrentDirectory - ()"}

11.3.3   Composing functions together
"In this context, the only parts that we’re really interested {in?} are the initial input and the final output"

Isaac Abraham (107) [Avatar] Offline
All done - thanks!