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

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]
主站蜘蛛池模板: 雅江县| 青岛市| 连平县| 常州市| 巴东县| 左贡县| 鲁甸县| 张掖市| 平陆县| 鲜城| 沙湾县| 永登县| 比如县| 彭州市| 彭州市| 丰顺县| 松溪县| 武城县| 万载县| 陆川县| 定陶县| 延吉市| 乌兰浩特市| 大丰市| 巴彦县| 温宿县| 稻城县| 铁岭县| 府谷县| 治县。| 巴马| 孟津县| 和平区| 云阳县| 荥阳市| 东源县| 喀喇| 二连浩特市| 松潘县| 宝清县| 龙游县|