F# - 在 F# 交互窗口中显示完整结果 [英] F# - Display full results in F# interactive window

查看:22
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆