-
Notifications
You must be signed in to change notification settings - Fork 1
interleave
Subhajit Sahu edited this page Feb 3, 2021
·
20 revisions
Place values from iterables alternately.
Similar: interleave, intermix, interpolate, intersperse.
function interleave(xs)
// xs: iterables
const xiterable = require('extra-iterable');
var x = [1, 2, 3, 4];
var y = [10, 20, 30, 40];
[...xiterable.interleave([x, y])];
// → [1, 10, 2, 20, 3, 30, 4, 40]
var y = [10, 20];
[...xiterable.interleave([x, y])];
// → [1, 10, 2, 20, 3, 4]