转换元组seq <string * =“”seq <string =“”>&gt;

时间:2015-09-03 14:05:39

标签: f# tuples

我必须将变量B::B(const B& a) : A(a) { y = new int[a.get_x()]; for (int i = 0; i < a.get_x(); i++) y[i] = a[i]; } 变为seq<string * seq<string>>

我有以下数据

seq<string * string>

我需要的是:

[
    ("hello", ["1";"2";"3";"4"]);
    ("hello2", ["2";"5";"3";"9"]);
    ("hello3", ["1";"12";"35";"46"])
]

单一功能是否可行?

2 个答案:

答案 0 :(得分:3)

我认为您正在寻找Seq.collect

$sitePage = Hash::remove($sitePage, 'SitePageGroup.{n}.site_page_id');

作为旁注,您在问题中错误地使用了“拆箱”一词。在.net中,装箱和拆箱有another meaning

答案 1 :(得分:2)

Seq.collect的替代方法是使用列表表达式:

[ for first, subElements in yourList do
    for second in subElements do
      yield first, second ]