Efficient conversion from String[] to F# List

后端 未结 3 1774
一个人的身影
一个人的身影 2021-01-12 14:57

I\'m coming to F# from a C# background and a little behind on the different lists and collections. I recently ran into a case where I needed to go from a string[] to \'T lis

相关标签:
3条回答
  • 2021-01-12 15:05

    Here's another way to do it:

    let listOfLines = [yield! File.ReadAllLines(@"C:\LinesOText.txt")]
    
    0 讨论(0)
  • 2021-01-12 15:16

    Use List.ofArray or Array.toList.

    0 讨论(0)
  • 2021-01-12 15:18

    this should do it:

    let lines = File.ReadAllLines(@"C:\LinesOText.txt") |> List.ofArray
    
    0 讨论(0)
提交回复
热议问题