F#学习第一天
let emptyList = []
let oneItem = "one" ::[]
let twoItem = "one" :: "two" ::[]
let shortHand = ["apples" ; "orange"]
let twoLists = twoItem @ shortHand
let objList = [box 1 ; box 2.0 ; box "three"]
for x in objList do
printf "%A," x
let listOfList = [[1;2;3];[4;5;6];[7;8;9;10]]
let rec concatList list =
if List.isEmpty list then
[]
else
let head = List.head list in
let tail = List.tail list in
head @ (concatList tail)
let resultList = concatList listOfList
printf "%A" resultList
for item in resultList do
printfn "%A" item
let (++!@) a b = a + b
let rec Fib num =
match num with
| 1 -> 1
| 2 -> 1
| num -> Fib (num - 1) ++!@ Fib (num - 2)
let resultFib = Fib 10
printfn "%i" resultFib
let test1= (function x -> function y -> x+y) 2 3
printfn "%i" test1
let emptyList = []
let oneItem = "one" ::[]
let twoItem = "one" :: "two" ::[]
let shortHand = ["apples" ; "orange"]
let twoLists = twoItem @ shortHand
let objList = [box 1 ; box 2.0 ; box "three"]
for x in objList do
printf "%A," x
let listOfList = [[1;2;3];[4;5;6];[7;8;9;10]]
let rec concatList list =
if List.isEmpty list then
[]
else
let head = List.head list in
let tail = List.tail list in
head @ (concatList tail)
let resultList = concatList listOfList
printf "%A" resultList
for item in resultList do
printfn "%A" item
let (++!@) a b = a + b
let rec Fib num =
match num with
| 1 -> 1
| 2 -> 1
| num -> Fib (num - 1) ++!@ Fib (num - 2)
let resultFib = Fib 10
printfn "%i" resultFib
let test1= (function x -> function y -> x+y) 2 3
printfn "%i" test1