官术网_书友最值得收藏!

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]
主站蜘蛛池模板: 海原县| 扎兰屯市| 雅江县| 普兰县| 滕州市| 海城市| 咸丰县| 吉首市| 永川市| 巴彦淖尔市| 安福县| 富锦市| 惠安县| 东安县| 广德县| 赣州市| 会昌县| 德惠市| 保康县| 七台河市| 枝江市| 泰宁县| 凤庆县| 天峨县| 黄石市| 连云港市| 东海县| 清镇市| 法库县| 榕江县| 宿松县| 城步| 常山县| 定结县| 铜鼓县| 宜城市| 台前县| 广南县| 海口市| 鄄城县| 沁阳市|