- .NET Core 2.0 By Example
- Rishabh Verma Neha Shrivastava
- 139字
- 2021-06-24 18:31:00
Calling a function
A function can be called by passing the function name followed, by a space, and then arguments (if any) separated by spaces, as shown here:
let sum = addValue 3
We can perform many tasks using F# functions, some of which are as follows:
- We can create a new function and link that function with a type as it acts as a variable type:
let square x = x*x - We can perform some calculations as well, such as:
let square x = x*x
- We can assign a value. Taking the same example:
let square x = x*x
- We can pass a function as a parameter to another function like this:
let squareValue = List.map square[1;2;3] // using square function
- We can return a function as a result of another function example:
let squareValue = List.map square[1;2;3]