序列内序列的Seq.map

时间:2015-10-27 18:34:22

标签: f# functional-programming

在进行Code Abbey练习时,我有很多代码,比如

seqOfSeqs
|> Seq.map (Seq.map Int32.Parse)
|> Seq.map (Seq.sum)

这看起来很难看,所以代号一吹进我的脑海

let actions seqs =
    seqs
    |> Seq.map Int32.Parse
    |> Seq.sum

seqOfSeq
|> Seq.map actions

对此有什么更好的解决方案?

1 个答案:

答案 0 :(得分:2)

这可能更简单:

seqOfSeqs|> Seq.map (Seq.sumBy System.Int32.Parse)