Skip to content

intermix

Subhajit Sahu edited this page May 19, 2020 · 13 revisions

Places values of an iterable between another. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:]

Similar: [interleave], [intermix], [intersperse], [interpolate].

iterable.intermix(x, y, [s], [t], [m], [n]);
// x: an iterable
// y: another iterable
// s: step size for x (1)
// t: step size for y (1)
// m: number of values from x (s)
// n: number of values from y (t)
const array = require('extra-array');

var x = [1, 2, 3, 4];
var y = [10, 20, 30];
array.intermix(x, [10]);
// [ 1, 10, 2, 10, 3, 10, 4 ]

array.intermix(x, y);
// [ 1, 10, 2, 20, 3, 30, 4 ]

array.intermix(x, y, 2);
// [ 1, 2, 10, 3, 4 ]

array.intermix(x, y, 1, 2);
// [ 1, 10, 20, 2, 30, 10, 3, 20, 30, 4 ]

references

Clone this wiki locally