- Notifications
You must be signed in to change notification settings - Fork5
splitAt
Subhajit Sahu edited this pageMay 3, 2023 ·13 revisions
Break array considering indices as separator.
functionsplitAt(x,is)// x: an array// is: indices (sorted)
constxarray=require('extra-array');varx=[1,2,2,3,5,4,4,7];xarray.splitAt(x,[1,2,5,6]);// → [ [ 1 ], [ 3, 5 ], [ 7 ] ]varx=[2,4,5,6,8];xarray.splitAt(x,[0,1,3,4]);// → [ [ 5 ] ]