0
可能有人請告訴我爲什麼下面的函數需要整數[],而不是字節[]爲什麼這個F#函數需要[],而不是字節數組的整數
type Node =
| InternalNode of int*Node*Node
| LeafNode of int * byte
let weight node =
match node with
|InternalNode(w,_,_) -> w
|LeafNode(w,_)-> w
let createNodes inputValues =
let getCounts (leafNodes:(int*byte)[])=
inputValues |>Array.iter
(fun b-> let (w,v) =leafNodes.[(int)b]
leafNodes.[(int)b]<-(w+1,v))
leafNodes
[|for b in 0uy..255uy -> (0 ,b)|] |>getCounts
|>List.ofArray
|>List.map LeafNode
很好的解釋從的作家最好的f#書。 thanx :) – 2010-04-19 17:02:12
@accidental coder:謝謝(對於這兩個讚美)! – 2010-04-19 18:38:27