-
Notifications
You must be signed in to change notification settings - Fork 5
filter
Subhajit Sahu edited this page Nov 20, 2022
·
25 revisions
Keep values which pass a test.
Alternatives: filter, filter$, filterAt.
Similar: map, filter, reject, reduce, accumulate.
function filter(x, ft)
// x: an array
// ft: test function (v, i, x)
const array = require('extra-array');
var x = [1, 2, 3, 4, 5];
array.filter(x, v => v % 2 === 1);
// → [ 1, 3, 5 ]
array.filter(x, v => v % 2 === 0);
// → [ 2, 4 ]
- Data.List.filter: Haskell
- Array.prototype.filter: MDN web docs
- array_filter: PHP
- _.remove: lodash
- _.without: lodash
- _.compact: lodash
- _.pull: lodash
- _.pullAll: lodash
- _.pullAllBy: lodash
- _.pullAllWith: lodash
- Array.filter: sugarjs
- Array.exclude: sugarjs
- Array.compact: sugarjs
- array-tools.where: @75lb