Skip to content

interleave

Subhajit Sahu edited this page May 3, 2023 · 17 revisions

Place values from iterables alternately.

Similar: interleave, intermix, interpolate, intersperse.


function interleave(xs)
// xs: arrays
const xarray = require('extra-array');

var x = [1, 2, 3, 4];
var y = [10, 20, 30, 40];
xarray.interleave([x, y]);
// → [ 1, 10, 2, 20, 3, 30, 4, 40 ]

var y = [10, 20];
xarray.interleave([x, y]);
// → [ 1, 10, 2, 20, 3, 4 ]


References

Clone this wiki locally