不时我得到看起来像这样的错误:F#签名理解:“ - >运算符和编译器错误”
opgave.fsx(28,14): error FS0001: This expression was expected to have type
'int'
but here has type
'int -> int'
opgave.fsx(33,35): error FS0001: This expression was expected to have type
'int list'
but here has type
'int -> int list -> int list'
什么混淆我是什么呢由->
运营商意味着什么?据我了解,然后从第一个错误,然后预计一个int,但是给出一个表达式,接受一个int并返回另一个int。也许我误解了?如果我是正确的,那究竟是什么问题?我可以发誓我之前做过类似的事情。
代码这些错误都是基于这个样子的:
member this.getPixelColors(x,y,p) : int list =
let pixel = image.GetPixel(x,y)
let stringPixel = pixel.ToString()
let rec breakFinder (s:string) (h:int) =
match s.[h] with
|',' -> s.[9..(h-1)] |> int
|_ -> (breakFinder(s (h+1))) // this is line 28
let rec yello x y p =
match x with
|l when l = imageW -> match y with
|k when k = imageH -> [email protected][(breakFinder stringPixel 0)]
|_ -> yello((0)(y+1)([email protected][(breakFinder stringPixel 0)])) // this is line 33
|_ -> yello((x+1)(y)([email protected][(breakFinder stringPixel 0)])) // there is an error in this line aswell identical to line 33
yello 0 0 []
有人可以让我明白,所以我将能够处理这个对我自己的未来?
如果添加行号,或也许把旁边的意见符合错误的行,这将帮助我们识别这里的问题。 – Stuart
我在代码中添加了评论。这是在每个递归调用它的错误 – Nulle
谢谢,这符合我的假设。请尝试我的答案,并告诉我是否有帮助。 – Stuart