-
Notifications
You must be signed in to change notification settings - Fork 1
splice
wolfram77 edited this page Apr 1, 2020
·
21 revisions
Removes or replaces existing values.
iterable.splice(x, i, [n], ...vs);
// x: an iterable
// i: remove index
// n: number of values to remove (rest)
// vs: values to insert
// --> [removed, iterable]
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4, 5];
iterable.splice(x, 2);
// [ [ 3, 4, 5 ], Iterable [ 1, 2 ] ]
iterable.splice(x, 2, 2);
// [ [ 3, 4 ], Iterable [ 1, 2, 5 ] ]
iterable.splice(x, 2, 2, 30, 40);
// [ [ 3, 4 ], Iterable [ 1, 2, 30, 40, 5 ] ]