F# functions

F# functions act like variables. We can declare and use them in the same way as we use variables in C#. A function definition starts with the let keyword, followed by the function name and parameters, a colon, its type, and the right-side expression, showing what the function does. The syntax is follows:

Let functionName parameters [ : returnType] = functionbody

In the preceding syntax:

  • functionName is an identifier of the function.
  • parameters gives the list of parameters separated by spaces. We can also specify an explicit type for each parameter and if not specified, the compiler tends to presume it from the function body as variables.
  • functionbody comprises an expression, or a compound expression, which has number of expressions. ...

Get .NET Core 2.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.