Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
The method would chop the list into pieces at a specified chop size (or chop sizes).
assert [1, 2, 3, 4].chop(1) == [[1]] assert [1, 2, 3, 4].chop(1,-1) == [[1], [2, 3, 4]] assert ('a'..'h').chop(2, 4) == [['a', 'b'], ['c', 'd', 'e', 'f']] assert ['a', 'b', 'c', 'd', 'e'].chop(3) == [['a', 'b', 'c']] assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 3) == [['a'], ['b', 'c'], ['d', 'e']] assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 3, 3, 3) == [['a'], ['b', 'c'], ['d', 'e'], [], []]