-
Notifications
You must be signed in to change notification settings - Fork 1
intermix
Subhajit Sahu edited this page Feb 3, 2021
·
15 revisions
Places values of an iterable between another. 🏃 📼 📦 🌔 📒
Similar: interleave, intermix, interpolate, intersperse.
iterable.intermix(x, y, [m], [n], [s], [t]);
// x: an iterable
// y: another iterable
// m: number of values from x (1)
// n: number of values from y (1)
// s: step size for x (m)
// t: step size for y (n)
const iterable = require("extra-iterable");
var x = [1, 2, 3, 4];
var y = [10, 20, 30];
[...iterable.intermix(x, [10])];
// [ 1, 10, 2, 10, 3, 10, 4 ]
[...iterable.intermix(x, y)];
// [ 1, 10, 2, 20, 3, 30, 4 ]
[...iterable.intermix(x, y, 2)];
// [ 1, 2, 10, 3, 4 ]
[...iterable.intermix(x, y, 1, 2)];
// [ 1, 10, 20, 2, 30, 10, 3, 20, 30, 4 ]