F# - Display full results in F# interactive window

后端 未结 4 2195
礼貌的吻别
礼貌的吻别 2021-01-04 06:03

Disclaimer: Total F# Newbie question!

If I type the following into an F# file in Visual Studio

#light

let squares =
    se         


        
相关标签:
4条回答
  • 2021-01-04 06:12

    If you want to display all the values in the sequence without transforming into a List, you can iterate directly on the sequence like so:

    Seq.iter (printfn "%A") squares
    

    Note that you're taking a risk: if, as Brian hints, the sequence is infinite, you could be in for a rather long wait. (In this case, Seq.skip and Seq.take are your friends)

    0 讨论(0)
  • 2021-01-04 06:13

    '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)
    
    0 讨论(0)
  • 2021-01-04 06:24

    An alternative is to set fsi.PrintLength to a suitably large number, e.g.

    > fsi.PrintLength <- 500
    
    0 讨论(0)
  • 2021-01-04 06:25

    If you get output like output"+[121 chars]

    fsi.PrintWidth <- 500
    

    Will make it output more to the console.

    0 讨论(0)
提交回复
热议问题