-
Notifications
You must be signed in to change notification settings - Fork 0
countAs
Subhajit Sahu edited this page Dec 28, 2022
·
14 revisions
Count occurrences of values.
function countAs(x, fm)
// x: lists
// fm: map function (v, k, x)
const xlists = require('extra-lists');
var x = [['a', 'b', 'c', 'd', 'e'], [1, 1, 2, 2, 4]];
xlists.countAs(x);
// → Map(3) { 1 => 2, 2 => 2, 4 => 1 }
var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
xlists.countAs(x, v => v % 2);
// → Map(2) { 1 => 2, 0 => 2 }