wrap_by_sizes¶
- emlib.misc.wrap_by_sizes(flatseq, packsizes)[source]¶
Wrap a flat seq using the given sizes
- Parameters:
flatseq (
list
) – a flat sequence of itemspacksizes (
Sequence
[int
]) – a list of sizes
- Return type:
list
[list
]- Returns:
a list of groups, where each group is of size as given by packsizes
Example
>>> flatseq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> wrap_by_sizes(flatseq, [3, 5, 2]) [[1, 2, 3], [4, 5, 6, 7, 8], [9, 10]]