我试图与PDC2008 Intro to F# video一起编码。我在下面显示的代码片段的最后一行中收到错误(演示者没有得到)“错误1此值不是函数,无法应用”。我在Visual Studio 2008 shell上运行Fsharp-1.9.6.2。最后一行中的startPrice
符号带有下划线红色,鼠标悬停时出现相同的错误。提前谢谢!
type StockAnalyzer (lprices, days) =
let prices =
lprices
|> Seq.map snd
|> Seq.take days
static member GetAnalyzers (tickers,days) =
tickers
|> Seq.map loadPrices
|> Seq.map (fun prices -> new StockAnalyzer (prices, days))
member s.Return =
let lastPrice = prices |> Seq.nth 0
let startPrice = prices |> Seq.nth (days - 1)
lastPrice / startPrice -1.
答案 0 :(得分:5)
尝试在“ - ”和“1”之间加一个空格。 F#编译器将-1解释为字面上的负值1而不是减1。