F#-在F#交互式窗口中显示完整结果 [英] F# - Display full results in F# interactive window
本文介绍了F#-在F#交互式窗口中显示完整结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
免责声明: 总数 F#新手问题!
如果我在Visual Studio中的F#文件中键入以下内容
If I type the following into an F# file in Visual Studio
#light
let squares =
seq { for x in 1 .. 10 -> x * x }
printf "%A" squares
并通过突出显示并按 Alt + Enter 在其上运行F#交互式,交互式窗口中的输出为
and run F# interactive on it by highlighting and pressing Alt+Enter, the output in the interactive window is
>
seq [1; 4; 9; 16; ...]
val squares : seq<int>
>
但是我想查看完整的序列,即
But I want to see the full sequence i.e.
>
seq [1; 4; 9; 16; 25; 36; 49; 64; 81; 100]
val squares : seq<int>
>
这可能吗?我希望有一个我错过的设置.
Is this possible? I'm hoping that there is a setting for this that I've missed.
推荐答案
'seq'是惰性计算的构造;它可能是无限的,这就是为什么FSI仅显示前几个值的原因.如果您想全部查看,则很简单的操作就是将其转换为列表,例如
'seq' is a lazily-evaluated construct; it could be infinite, which is why FSI only shows the first few values. If you want to see it all, an easy thing to do is convert to a list, e.g.
printf "%A" (squares |> Seq.tolist)
这篇关于F#-在F#交互式窗口中显示完整结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文