2008-12-02 68 views
3

我試圖與PDC2008 Intro to F# video一起編碼。我在下面顯示的代碼片段的最後一行中得到一個錯誤(演示者沒有得到)「錯誤1這個值不是一個函數,也不能應用」。我在Visual Studio 2008外殼上運行Fsharp-1.9.6.2。最後一行中的startPrice符號在鼠標懸停時帶有相同的錯誤,並帶有下劃線。提前致謝!爲什麼「-1」不能減1?

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. 

回答

5

嘗試在「 - 」和「1」之間加一個空格。 F#編譯器將-1解釋爲1,而不是1的負值。