Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

I have created today a question which was a duplicate of this (thanks to Pinguin DirkPinguin Dirk).

My attepmts are not very spophisticated but one may find them useful:

Let f[k] be a list of lengths:

l = Range[10]; p = {2, 3, 5}; 

1

Take[l, {1, 0} + #] & /@ (Partition[Prepend[Accumulate@p, 0], 2, 1]) 

{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}

2

FoldList[{Take[#1[[ 2]], #2], Drop[#1[[ 2]], #2]} &, {1, l}, p ][[ ;; , 1]] // Rest 

{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}

I have created today a question which was a duplicate of this (thanks to Pinguin Dirk).

My attepmts are not very spophisticated but one may find them useful:

Let f[k] be a list of lengths:

l = Range[10]; p = {2, 3, 5}; 

1

Take[l, {1, 0} + #] & /@ (Partition[Prepend[Accumulate@p, 0], 2, 1]) 

{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}

2

FoldList[{Take[#1[[ 2]], #2], Drop[#1[[ 2]], #2]} &, {1, l}, p ][[ ;; , 1]] // Rest 

{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}

I have created today a question which was a duplicate of this (thanks to Pinguin Dirk).

My attepmts are not very spophisticated but one may find them useful:

Let f[k] be a list of lengths:

l = Range[10]; p = {2, 3, 5}; 

1

Take[l, {1, 0} + #] & /@ (Partition[Prepend[Accumulate@p, 0], 2, 1]) 

{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}

2

FoldList[{Take[#1[[ 2]], #2], Drop[#1[[ 2]], #2]} &, {1, l}, p ][[ ;; , 1]] // Rest 

{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}

Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803

I have created today a question which was a duplicate of this (thanks to Pinguin Dirk).

My attepmts are not very spophisticated but one may find them useful:

Let f[k] be a list of lengths:

l = Range[10]; p = {2, 3, 5}; 

1

Take[l, {1, 0} + #] & /@ (Partition[Prepend[Accumulate@p, 0], 2, 1]) 

{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}

2

FoldList[{Take[#1[[ 2]], #2], Drop[#1[[ 2]], #2]} &, {1, l}, p ][[ ;; , 1]] // Rest 

{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}