F# split sequence into sub lists on every nth element

后端 未结 8 862
时光说笑
时光说笑 2020-12-06 11:23

Say I have a sequence of 100 elements. Every 10th element I want a new list of the previous 10 elements. In this case I will end up with a list of 10 sublists.

Seq.t

8条回答
  •  独厮守ぢ
    2020-12-06 12:05

    now there's Seq.chunkBySize available:

    [1;2;3;4;5] |> Seq.chunkBySize 2 = seq [[|1; 2|]; [|3; 4|]; [|5|]]
    

提交回复
热议问题