gpt4 book ai didi

f# - F#中的打印序列

转载 作者:行者123 更新时间:2023-12-04 09:34:00 25 4
gpt4 key购买 nike

我对 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>'

任何帮助,将不胜感激。

最佳答案

printf 不带括号:

printfn "%A" prices;;

(详见 F# function types: fun with tuples and currying)

您也可以将 seq 转换为列表,例如
printfn "%A" (Seq.toList prices);;

关于f# - F#中的打印序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1294232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com