-
Notifications
You must be signed in to change notification settings - Fork 0
range
Subhajit Sahu edited this page Jun 18, 2020
·
15 revisions
Finds smallest and largest entries. 🏃 📼 📦 🌔 📒
lists.range(x, [fc], [fm]);
// x: lists
// fc: compare function (a, b)
// fm: map function (v, k, x)
// --> [smallest, largest]
const lists = require('extra-lists');
var x = [['a', 'b', 'c', 'd'], [1, 2, -3, -4]];
lists.range(x);
// [ [ 'd', -4 ], [ 'b', 2 ] ]
lists.range(x, (a, b) => Math.abs(a) - Math.abs(b));
// [ [ 'a', 1 ], [ 'd', -4 ] ]
lists.range(x, null, v => Math.abs(v));
// [ [ 'a', 1 ], [ 'd', -4 ] ]