/// I can't do this
let max = float n |> sqrt |> int64 |> Math.BigInt
/// But this is allowed
let max = Math.BigInt(float n |> sqrt |> int64)
问问题
606 次
2 回答
3
类构造函数不能在没有参数的情况下使用。你可以写
let max = float n |> sqrt |> int64 |> (fun x -> Math.BigInt(x))
如果你喜欢。(不过,我不知道这种限制的原因。)
于 2009-05-11T03:43:42.097 回答
0
在我的 F# 版本(Mono 上的 1.9.4.19)中,两个版本都失败了:
The member or object constructor 'BigInt' takes 0 argument(s) but is here given 1. The required signature is 'Math.BigInt()'.
我可以用
let max = float n |> sqrt |> int64 |> Math.BigInt.of_int64
得到一个bigint
或
let max = float n |> sqrt |> int64 |> Math.BigInt.FromInt64
得到一个Math.BigInt
.
于 2009-05-11T14:33:59.873 回答