Skip to content

searchMinimumValue

Subhajit Sahu edited this page May 3, 2023 · 1 revision

Find first index of minimum value.

Similar: searchMinimumValue, searchMaximumValue.


function searchMinimumValue(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.searchMinimumValue(x);
// → 3

xarray.searchMinimumValue(x, (a, b) => Math.abs(a) - Math.abs(b));
// → 0

xarray.searchMinimumValue(x, null, v => Math.abs(v));
// → 0


References

Clone this wiki locally