@stdlib/array-base-indices-complement
v0.1.1
Published
Return the complement of a list of array indices.
Readme
indicesComplement
Return the complement of a list of array indices.
Installation
npm install @stdlib/array-base-indices-complementUsage
var indicesComplement = require( '@stdlib/array-base-indices-complement' );indicesComplement( N, indices )
Returns the complement of a list of array indices.
var idx = indicesComplement( 5, [ 1, 2 ] );
// returns [ 0, 3, 4 ]The function accepts the following arguments:
- N: array length.
- indices: list of indices from which to derive the complement.
Notes
- The function always returns a new "generic" array.
Examples
var indicesComplement = require( '@stdlib/array-base-indices-complement' );
var out = indicesComplement( 5, [ 1, 3, 4 ] );
// returns [ 0, 2 ]
out = indicesComplement( 5, [ 0, 1 ] );
// returns [ 2, 3, 4 ]
out = indicesComplement( 5, [ 0 ] );
// returns [ 1, 2, 3, 4 ]
out = indicesComplement( 5, [] );
// returns [ 0, 1, 2, 3, 4 ]
out = indicesComplement( 5, [ 0, 1, 2, 3, 4 ] );
// returns []Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
