F#学习笔记
(1)let list1 = [1;2;3] 这好像是个数组,
List.sum list1 求和
(2)递归函数
let rec fib n =
if n < 2
then 1
else
fib(n-1) + fib(n-2)
(3)
let apply1(transform:int ->int) y = transform y
let increment x =
x + 1
let result1 = apply1 increment 100
(4)Lamda表达式
let result5 = apply1 (fun x->x+1) 100
(5)函数组合
let function1 x = x + 100
let function2 x = x * 2
let function3 = function1 >> function2
let function4 = function2 >> function1
let result8 = function4 9
let result7 = function3 9
let result9 = 9 |> function1 |>function2