Skip to content

splitAt

Subhajit Sahu edited this page Feb 3, 2021 · 9 revisions

Break iterable considering indices as separator.

Alternatives: split, splitAt.
Similar: cut, split, group.


function splitAt(x, is)
// x:  an iterable
// is: indices (sorted)
const xiterable = require('extra-iterable');

var x = [1, 2, 2, 3, 5, 4, 4, 7];
[...xiterable.splitAt(x, [1, 2, 5, 6])];
// → [[1], [3, 5], [7]]

var x = [2, 4, 5, 6, 8];
[...xiterable.splitAt(x, [0, 1, 3, 4])];
// → [[5]]


References

Clone this wiki locally