我有以下函数,它接受一个实数并计算它的连分数。但是我尝试使用匹配来实现它,但我不知道它是否可能了,因为我需要进行以下检查 b < 0.0000000001,但我不知道如何在没有 if 语句的情况下仅使用匹配来完成,我需要能够利用 < 运算符
let rec floatfrac (x : float) : int list =
let a = int x
let b = x - (float a)
match b with
| b < 0.0000000001 -> [] // error here because wrong syntax
| _ -> (floatfrac (1.0 / b ))
printfn "%A" (floatfrac 3.14)
错误 FS0010:模式中出现意外的浮点文字。预期的中缀运算符、引号符号或其他标记。