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