我已尽一切努力使编译器能够监听。但是,它拒绝理解。我正在尝试比较每个元素的颜色值,如果它们相同,则返回true,否则返回false。
我放置了想要的约束,但仍然无法确定类型。
let all_same_color cs =
let mutable d=true
let (col:Color) = card_color (cs.Head:Card)
for i in cs do
let col=card_color i
if not (col = col) then
printfn "Black"
d<-false
else
d<-d
printfn "Val %b" d
d
Run Code Online (Sandbox Code Playgroud)
我希望如果颜色匹配则返回true,否则返回false。
它在这一行不断出错:
let (col:Color) = card_color (cs.Head:Card)
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this programpoint to constrain the type of the object. This may allow the …Run Code Online (Sandbox Code Playgroud)