[英]F#: expected 'in' or other token error
So I've written a pretty simple program in F# that should sum all of the multiples of 3 and 5 below 1000: 所以我在F#中编写了一个非常简单的程序,它应该将所有3和5的倍数加在1000以下:
[1..999]
|> List.filter (fun x -> x % 3 = 0 || x % 5 = 0)
|> let total = List.sum`
However, at the very end of the program I get the following error: 但是,在程序的最后,我收到以下错误:
Unexpected end of input in expression. Expected 'in' or other token.
I am using the lightweight syntax, so I'm not sure why F# would want me to use an 'in' statement. 我使用轻量级语法,所以我不确定为什么F#会要我使用'in'语句。 Any thoughts?
有什么想法吗?
You probably intended to do this: 你可能打算这样做:
let total =
[1..999]
|> List.filter (fun x -> x % 3 = 0 || x % 5 = 0)
|> List.sum
The error message you are getting is because it expects a function after the forward pipe, you can have a let binding but as part of a function expecting at least one parameter. 您获得的错误消息是因为它期望在正向管道之后的函数,您可以具有let绑定但作为期望至少一个参数的函数的一部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.