Created
March 5, 2014 11:54
-
-
Save thinktainer/9365834 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Seq = | |
let private spill (n:int) (s:seq<'a>) = | |
let en = s.GetEnumerator() | |
let pos = ref 0 | |
let lst = [ while !pos < n && en.MoveNext() do | |
pos := !pos+1 | |
yield en.Current] | |
if lst |> List.isEmpty then None else | |
Some((lst, seq { while en.MoveNext() do yield en.Current})) | |
[<CompiledName("Batch")>] | |
let batch (batchSize :int) = | |
Seq.unfold (spill batchSize) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment