Skip to content

rangeEntries

Subhajit Sahu edited this page Feb 3, 2021 · 1 revision

Find smallest and largest entries.

Similar: min, minEntry, max, maxEntry, range, rangeEntries.


function rangeEntries(x, fc, fm)
// x:  an iterable
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xiterable = require('extra-iterable');

var x = [1, 2, -3, -4];
xiterable.rangeEntries(x);
// → [[3, -4], [1, 2]]

xiterable.rangeEntries(x, (a, b) => Math.abs(a) - Math.abs(b));
// → [[0, 1], [3, -4]]

xiterable.rangeEntries(x, null, v => Math.abs(v));
// → [[0, 1], [3, -4]]


References

Clone this wiki locally