下面是我的代码:
open System
let rec gcd a b =
match b with
| x when x = 0 -> a
| _ -> gcd(b, a % b)
let result = gcd 15 10
[<EntryPoint>]
let main(args : string[]) =
printfn "result = %d" result
0为什么我会得到以下代码的错误:
D:\datahub\Dropbox\development\myprojects\project-euler\Problem_5\problem_5.fs(6,16): error FS0001: Type mismatch. Expec
ting a
'a
but given a
int -> 'a
The resulting type would be infinite when unifying ''a' and 'int -> 'a'发布于 2011-06-24 19:51:54
该示例尝试使用逗号分隔参数。在F#中,通过使用空格分隔多个参数,将多个参数提供给函数:
let rec gcd a b =
match b with
| x when x = 0 -> a
| _ -> gcd b (a % b)https://stackoverflow.com/questions/6467236
复制相似问题