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