I have a collection (a list of states) that I want to chunk into a collection of collections (ex. a slice of slices). The code below accomplishes my goal. Is there an easier way?
Ideally I could do something like below. This would give me a slice of five slices. Each subslice containing an equal number of items, except for the last subslice which would contain the remainder.
empty arrays are added if the bucket_count is greater then length of list
try it with array size = 4 and bucket count = 3
according to your definition it should give [ [One], [Two], [Three, Four]]
but the result is [ [One, Two], [Three, Four], []]