stdlib-js / stdlib

✨ Standard library for JavaScript and Node.js. ✨
https://stdlib.io
Apache License 2.0
4.18k stars 405 forks source link

[RFC]: add `@stdlib/array/base/cusome` #2322

Open kgryte opened 1 month ago

kgryte commented 1 month ago

Description

This RFC proposes adding the package @stdlib/array/base/cusome, which cumulatively tests whether at least n array elements in a provided array are truthy. The function should return a new generic array. The package should also provide an #assign API for setting output values in a provided output array.

var x = [ false, false, false, true, true ];

var y1 = cusome( x, 2 );
// returns [ false, false, false, false, true ]

var y2 = [ false, null, false, null, false, null, false, null, false, null ];
var out = cusome.assign( x, 2, y2, 2, 0 );
// returns [ false, null, false, null, false, null, false, null, true, null ]

where the assign API supports an offset and stride (see, e.g., @stdlib/array/base/take).

Both APIs should support accessor arrays (see, e.g., @stdlib/array/base/take).

Related Issues

No.

Questions

No.

Other

No.

Checklist

vr-varad commented 1 week ago

@kgryte feeling great to be here again!!! I wanted to work on this issue.

kgryte commented 1 week ago

@vr-varad Thanks for volunteering to work on this. Feel free to submit a PR. There's already some precedent with array/base/cuevery and array/base/cuany.