-
Notifications
You must be signed in to change notification settings - Fork 5
splitAt
Subhajit Sahu edited this page Jun 20, 2020
·
13 revisions
Breaks iterable considering indices as separator. 🏃 📼 📦 🌔 📒
array.splitAt(x, is);
// x: an iterable
// is: indices (sorted)
const iterable = require('extra-iterable');
var x = [1, 2, 2, 3, 5, 4, 4, 7];
[...iterable.splitAt(x, [1, 2, 5, 6])];
// [ [ 1 ], [ 3, 5 ], [ 7 ] ]
var x = [2, 4, 5, 6, 8];
[...iterable.splitAt(x, [0, 1, 3, 4])];
// [ [ 5 ] ]