Module F#格式不良的模块
您好,下面的代码有什么问题,我的错误是: 无与伦比的{这主要是由于我的标签, 无效的记录、序列或计算表达式。序列表达式的格式应为“seq{…}” 表达式中此点或之前的不完整结构化构造Module F#格式不良的模块,module,f#,Module,F#,您好,下面的代码有什么问题,我的错误是: 无与伦比的{这主要是由于我的标签, 无效的记录、序列或计算表达式。序列表达式的格式应为“seq{…}” 表达式中此点或之前的不完整结构化构造 module records = let debate(irthes:DateTime) = { let mutable manch = nexttime(irthes) let mutable array1: DateTime array =
module records =
let debate(irthes:DateTime) =
{
let mutable manch = nexttime(irthes)
let mutable array1: DateTime array = Array.zeroCreate 480
for i in 0 .. 480-1 do
Array.set array1 i (manch)
let next = Array.get array1 i
let! manch=nexttime(next)
return(array1)
}
我想你想要这样的东西:
module records =
let debate(irthes:DateTime) =
let mutable manch = nexttime(irthes)
let array1: DateTime array = Array.zeroCreate 480
for i in 0 .. 480-1 do
array1.[i] <- manch
manch <- nexttime manch
array1
模块记录=
让我们进行辩论(irthes:DateTime)=
设可变manch=nexttime(irthes)
让array1:DateTime数组=array.zeroCreate 480
对于0..480-1中的i
array1。[i]关于您尝试执行的操作,甚至没有多少是有效的。首先,您似乎正在尝试初始化一个记录——为此,您必须将字段分配给=
的值,如下所示:
type Person = { name: string; address: string }
let joe = { name = "Joe Smith"; address: "1600 Pennsylvania Avenue NW, Washington, 20500" }
此外,F#没有提前退出(return
);任何函数/方法的结果都只是最后一个表达式的结果:
let increment n = n + 1
因此,没有返回n+1
。另外,let!
仅用于计算表达式中。但是,如果您想将变量,foo
例如,变为42,请使用foo提供您收到的完整错误输出。在使用与缩进相关的语言时,如果您认为in存在问题齿(标签),然后首先修复。