-
Notifications
You must be signed in to change notification settings - Fork 5
intersperse
Subhajit Sahu edited this page May 3, 2023
·
13 revisions
Place a separator between every value.
Similar: interleave, intermix, interpolate, intersperse.
function intersperse(x, v)
// x: an array
// v: separator
const xarray = require('extra-array');
var x = [1, 2, 3];
xarray.intersperse(x, 10);
// → [ 1, 10, 2, 10, 3 ]
var x = [1, 2, 3, 4];
xarray.intersperse(x, 10);
// → [ 1, 10, 2, 10, 3, 10, 4 ]