partitionAs - nodef/extra-lists GitHub Wiki
Segregate entries by similarity.
Alternatives: partition, partitionAs.
function partitionAs(x, fm)
// x: entries
// fm: map function (v, k, x)
const xlists = require('extra-lists');
var x = ['a', 'b', 'c', 'd'], [1, 2, 3, 4](/nodef/extra-lists/wiki/'a',-'b',-'c',-'d'],-[1,-2,-3,-4);
xlists.partitionAs(x, v => v % 2 == 0);
// → Map(2) {
// → false => [ [ 'a', 'c' ], [ 1, 3 ] ],
// → true => [ [ 'b', 'd' ], [ 2, 4 ] ]
// → }
var x = ['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5](/nodef/extra-lists/wiki/'a',-'b',-'c',-'d',-'e'],-[1,-2,-3,-4,-5);
xlists.partitionAs(x, v => v % 3);
// → Map(3) {
// → 1 => [ [ 'a', 'd' ], [ 1, 4 ] ],
// → 2 => [ [ 'b', 'e' ], [ 2, 5 ] ],
// → 0 => [ [ 'c' ], [ 3 ] ]
// → }