Skip to content
Subhajit Sahu edited this page Dec 28, 2022 · 17 revisions

Keep entries which pass a test.

Similar: map, reduce, filter, filterAt, reject, rejectAt.


function filter(x, ft)
// x:  ilists
// ft: test function (v, k, x)
const xilists = require('extra-ilists');

var x = [['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]];
xilists.filter(x, v => v % 2 === 1);
// → [ [ 'a', 'c', 'e' ], [ 1, 3, 5 ] ]

xilists.filter(x, v => v % 2 === 0);
// → [ [ 'b', 'd' ], [ 2, 4 ] ]


References

Clone this wiki locally