从String []到F#List的有效转换 [英] Efficient conversion from String[] to F# List
本文介绍了从String []到F#List的有效转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从C#的背景来到F#,在不同的列表和集合上有点落后。我最近遇到了一个case,我需要从一个字符串[]到'T列表。我最后使用列表推导做演员:
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 list. I ended up using list comprehension to do the cast:
let lines = File.ReadAllLines(@"C:\LinesOText.txt") // returns a string array
let listOLines = [for l in lines -> l] // use list comprehension to get the f# list
转换?
推荐答案
使用 List.ofArray
或 Array.toList
。
这篇关于从String []到F#List的有效转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文