Home
Insert
Update snippet 'Split array into chunks'
Title
Description
Splits array into chunks, returning seq of seqs. Works with F# 3.x
Source code
let chunk chunkSize (arr : _ array) = query { for idx in 0..(arr.Length - 1) do groupBy (idx / chunkSize) into g select (g |> Seq.map (fun idx -> arr.[idx])) }
Tags
collections
collections
Author
Link
Reference NuGet packages
If your snippet has external dependencies, enter the names of NuGet packages to reference, separated by a comma (
#r
directives are not required).
Update