minEntry - nodef/extra-lists GitHub Wiki

Find smallest entry.

Similar: min, max, range.

function minEntry(x, fc, fm)
// x:  lists
// fc: compare function (a, b)
// 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.minEntry(x);
// → [ 'd', -4 ]

xlists.minEntry(x, (a, b) => Math.abs(a) - Math.abs(b));
// → [ 'a', 1 ]

xlists.minEntry(x, null, v => Math.abs(v));
// → [ 'a', 1 ]

References