Skip to content

filter$

Subhajit Sahu edited this page Feb 2, 2021 · 34 revisions

Keeps values which pass a test. 📦 😺 🏃 📼 🌔 📜 📰 📘

Alternatives: filter, filter$, filterAt.
Similar: map, filter, reject, reduce, accumulate.


array.filter$(x, ft);
// x:  an array (updated)
// ft: test function (v, i, x)
// → x
const array = require("extra-array");

var x = [1, 2, 3, 4, 5];
array.filter$(x, v => v % 2 === 1);
// [ 1, 3, 5 ]

x;
// [ 1, 3, 5 ]

var x = [1, 2, 3, 4, 5];
array.filter$(x, v => v % 2 === 0);
// [ 2, 4 ]


References

Clone this wiki locally