2009-08-18 58 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