Skip to content

Instantly share code, notes, and snippets.

@localhots
Created April 5, 2016 12:15
Show Gist options
  • Save localhots/f8b59c507353a5db8ca6af08b91cb83b to your computer and use it in GitHub Desktop.
Save localhots/f8b59c507353a5db8ca6af08b91cb83b to your computer and use it in GitHub Desktop.
func processWithBatches(items []uint32, batchSize int, f func(batch []uint32)) {
if len(items) == 0 {
return
}
if len(items) <= batchSize {
f(items)
} else {
f(items[:batchSize])
processWithBatches(items[batchSize:], batchSize, f)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment