Skip to content

rangeEntries

Subhajit Sahu edited this page May 3, 2023 · 3 revisions

Find smallest and largest entries.

Alternatives: range, rangeEntries.
Similar: minimum, maximum, range.


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

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

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

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


References

Clone this wiki locally