我一直试图在F#中创建一个可以通过另一个文件读取文本的代码,但是我一直看到
此“ let”之后的块未完成。每个代码块都是一个表达式,必须有一个结果
在
let a = line.Split delim
,我查了一下,认为这是一个缩进错误,但这并不能解决。有什么建议吗?
[<EntryPoint>]
let main argv =
let delim = ','
use stream = new StreamReader @"final.txt"
let line = stream.Readline()
let a = line.Split delim
|>Seq.map System.Int32.Parse
|>Seq.toArray
printfn "Orignal numbers: %A" a
printfn "Ordered numbers: %A" (oddEven a)
0 // return an integer exit code
答案 0 :(得分:3)
您缺少缩进(并且拼错了一两件事)。您想成为let
块的任何内容都必须缩进一个级别。这是正确格式化的代码:
[<EntryPoint>]
let main argv =
let delim = ','
use stream = new StreamReader @"final.txt"
let line = stream.ReadLine()
let a =
line.Split delim
|> Seq.map System.Int32.Parse
|> Seq.toArray
printfn "Orignal numbers: %A" a
printfn "Ordered numbers: %A" (oddEven a)
0 // return an integer exit code