-
Notifications
You must be signed in to change notification settings - Fork 1
countAs
Subhajit Sahu edited this page Feb 3, 2021
·
17 revisions
Count occurrences of values.
function countAs(x, fm)
// x: an array
// fm: map function (v, i, x)
const xiterable = require('extra-iterable');
var x = [1, 1, 2, 2, 4];
xiterable.countAs(x);
// → xiterable.Map(3) { 1 => 2, 2 => 2, 4 => 1 }
var x = [1, 2, 3, 4];
xiterable.countAs(x, v => v % 2);
// → xiterable.Map(2) { 1 => 2, 0 => 2 }