Last active
May 5, 2017 16:11
-
-
Save SteveGilham/f1db5bc38de112bb645fc5b0a8e69220 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let chunk n (source : seq<'a>) = | |
let makechunk (source : System.Collections.Generic.IEnumerator<'a>) n = | |
seq { yield source.Current | |
let mutable i = 0 | |
while (i < n) && source.MoveNext() do | |
yield source.Current | |
i <- i + 1 | |
} | |
seq { use enumerator = source.GetEnumerator() | |
while enumerator.MoveNext() do | |
yield makechunk enumerator (n-1) | |
};; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment