if reelID = reelWeights.Count - 1
then Array.fold calc1 (0L,0) reelWeights.[reelID]
else Array.fold calc2 (0L,0) reelWeights.[reelID]
我尝试使用管道,它似乎有点慢(不知道为什么):
reelWeights.[reelID]
|> (if reelID = reelWeights.Count - 1 then Array.fold calc1 else Array.fold calc2) (0L,0)
如果我做
let calc x = if x then calc1 else calc2
Array.fold (calc reelID = reelWeights.Count - 1) (0L,0) reelWeights.[reelID]
那么它看起来不错,代价是在循环中冗余检查条件。