-
Notifications
You must be signed in to change notification settings - Fork 1
difference
Subhajit Sahu edited this page May 17, 2020
·
28 revisions
Gives values of an iterable not present in another. 🏃 📼 📦 🌔 📒
iterable.difference(x, y, [fc], [fm]);
// x: an iterable
// y: another iterable
// fc: compare function (a, b)
// fm: map function (v, i, x)
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4, 5];
var y = [2, 4];
[...iterable.difference(x, y)];
// [ 1, 3, 5 ]
var y = [-2, -4];
[...iterable.difference(x, y)];
// [ 1, 2, 3, 4, 5 ]
[...iterable.difference(x, y, (a, b) => Math.abs(a) - Math.abs(b))];
// [ 1, 3, 5 ]