2009-08-18 80 views
4

我對F#很新,所以請原諒完全新手的問題:在F#中的打印序列#

我有一個序列存儲在一個叫做價格的變量中。我想輸出這個序列的內容到交互式窗口。最簡單的命令是什麼?

這裏是我的序列:

> prices;; 
val it : seq<System.DateTime * float> = seq [] 

我試過printf'ing它,但是給我的錯誤:

> printf("%A", prices);; 

    printf("%A", prices);; 
    -------^^^^^^^^^^^^ 

stdin(82,8): error FS0001: The type ''b * 'c' is not compatible with the type 'Printf.TextWriterFormat<'a>' 

任何幫助,將不勝感激。

回答

14

的printf並不需要括號:

printfn "%A" prices;; 

(見F# function types: fun with tuples and currying瞭解詳細信息)

您也可以指定seq轉換到一個列表,例如

printfn "%A" (Seq.toList prices);; 
+0

感謝您的真棒鏈接。 printfn正是我所期待的。 – rein 2009-08-18 14:45:10

2
> prices;; 
val it : seq<System.DateTime * float> = seq [] 

它正在完成其工作:seq []表示序列爲空。

+0

謝謝。這解釋了很多:) – rein 2009-08-18 14:44:38