Using Partition to allow sublists of different lengths
Yes, this is the correct syntax:
Partition[list, 10, 10, 1, {}]
The fourth argument is a short form of {1, 1}
so the full form is:
Partition[list, 10, 10, {1, 1}, {}]
As the documentation says:
Partition[list, n, d, {kL, kR}]
specifies that the first element of list should appear at position kL in the first sublist, and the last element of list should appear at or after position kR in the last sublist. If additional elements are needed, Partition fills them in by treating list as cyclic.
You need the arguments 10, 10
because this means lengths of ten without overlap. (Take 10, move over ten, take another ten...)
Since Mathematica 10.3, we can use the much more convenient UpTo
:
Partition[Range[25], UpTo[10]]
(* {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
{11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
{21, 22, 23, 24, 25}} *)
Just to show Internal`PartitionRagged
:
r = Range[25];
qr[m_, n_] :=
Module[{a = QuotientRemainder[m, n]},
Table[n, {a[[1]]}]~Join~{a[[2]]}]
Internal`PartitionRagged[r, qr[25, 10]]
yields:
{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {11, 12, 13, 14, 15, 16, 17, 18, 19,
20}, {21, 22, 23, 24, 25}}