@stdlib/array-base-cusome
v0.1.1
Published
Cumulatively test whether at least `n` array elements in a provided array are truthy.
Readme
cusome
Cumulatively test whether at least
narray elements in a provided array are truthy.
Installation
npm install @stdlib/array-base-cusomeUsage
var cusome = require( '@stdlib/array-base-cusome' );cusome( x, n )
Cumulatively tests whether at least n array elements in a provided array are truthy.
var x = [ false, false, false, true, true ];
var y = cusome( x, 2 );
// returns [ false, false, false, false, true ];cusome.assign( x, n, y, stride, offset )
Cumulatively tests whether at least n array elements in a provided array are truthy and assigns results to a provided output array.
var x = [ false, false, false, true, true ];
var y = [ false, null, false, null, false, null, false, null, false, null ];
var out = cusome.assign( x, 2, y, 2, 0 );
// returns [ false, null, false, null, false, null, false, null, true, null ]
var bool = ( out === y );
// returns trueThe function supports the following parameters:
- x: input array.
- n: number of elements.
- out: output array.
- stride: output array stride.
- offset: output array offset.
Examples
var bernoulli = require( '@stdlib/random-array-bernoulli' );
var cusome = require( '@stdlib/array-base-cusome' );
// Create an array of random values:
var x = bernoulli( 10, 0.3 );
console.log( x );
// Cumulatively test whether at least two array elements are truthy:
var out = cusome( x, 2 );
console.log( out );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.
