Given an integer, say 20, how can I create the following irregular list of lists?
lst={5,7,3,5};
Range[#]&/@lst;
generates this:
{{1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6, 7}, {1, 2, 3}, {1, 2, 3, 4, 5}}
I like to have the following list of lists:
{{1,2,3,4,5}, {6,7,8,9,10,11,12}, {13,14,15}, {16,17,18,19,20}}
If the list of lists was a regular sequence, I could use:
Partition[Range[20], 5]]
TakeList[Range@ Total@(a = {5, 7, 3, 5}), a]
$\endgroup$TakeList[Range@Total@#,#]&@lst
$\endgroup$Range[#]&/@lst;
could beRange/@lst;
$\endgroup$Range@lst
! $\endgroup$