searchAdjacentDuplicateValue - nodef/extra-array GitHub Wiki

Find first index of an adjacent duplicate value.

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


// Example for searchAdjacentDuplicateValue
var x = [1, 2, 3, 4, 5];
xarray.searchAdjacentDuplicateValue(x);
// → -1

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

References