Skip to main content
deleted 1 character in body
Source Link
Karsten7
  • 27.7k
  • 5
  • 76
  • 138

This can be implemented elegantly with FoldPairList and TakeDrop (both new in v10.2), in fact it's one of the examples in the documentation:

FoldPairList[TakeDrop, Range[10], {2, 3, 5}]
{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}`
FoldPairList[TakeDrop, Range[20], Range[5]]
{{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}

This can be implemented elegantly with FoldPairList and TakeDrop (both new in v10.2), in fact it's one of the examples in the documentation:

FoldPairList[TakeDrop, Range[10], {2, 3, 5}]
{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}`
FoldPairList[TakeDrop, Range[20], Range[5]]
{{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}

This can be implemented elegantly with FoldPairList and TakeDrop (both new in v10.2), in fact it's one of the examples in the documentation:

FoldPairList[TakeDrop, Range[10], {2, 3, 5}]
{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}
FoldPairList[TakeDrop, Range[20], Range[5]]
{{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}
Bumped for more exposure.
Source Link
István Zachar
  • 47.2k
  • 20
  • 149
  • 308

This can be implemented elegantly with FoldPairListFoldPairList and TakeDrop (both new in v10.2), in fact it's one of the examples in the documentation:

FoldPairList[TakeDrop, Range[10], {2, 3, 5}]

FoldPairList[TakeDrop, Range[10], {2, 3, 5}]

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

{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}`
FoldPairList[TakeDrop, Range[20], Range[5]]
{{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}

This can be implemented elegantly with FoldPairList, in fact it's one of the examples:

FoldPairList[TakeDrop, Range[10], {2, 3, 5}]

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

This can be implemented elegantly with FoldPairList and TakeDrop (both new in v10.2), in fact it's one of the examples in the documentation:

FoldPairList[TakeDrop, Range[10], {2, 3, 5}]
{{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}`
FoldPairList[TakeDrop, Range[20], Range[5]]
{{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}
Source Link
masterxilo
  • 5.8k
  • 20
  • 41

This can be implemented elegantly with FoldPairList, in fact it's one of the examples:

FoldPairList[TakeDrop, Range[10], {2, 3, 5}]

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