Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. ClearAll@splitList;
  2. splitList[1][list_] := {list};
  3. splitList[parts_Integer][list_] :=
  4. With[{n = Ceiling[Length[list]/parts]},
  5. Partition[list, UpTo[n]] //
  6. Replace[
  7. {prev : Repeated[{___}, parts - 1]} :>
  8. {prev, Apply[Sequence]@Table[{}, {parts - Length@{prev}}] }
  9. ]
  10. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement