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