@extra-array/cut
Version:
Breaks array when test passes.
50 lines (36 loc) • 1.41 kB
Markdown
Breaks array when test passes.
[:package:](https://www.npmjs.com/package/@extra-array/cut)
[:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array)
[:running:](https://npm.runkit.com/@extra-array/cut)
[:vhs:](https://asciinema.org/a/332035)
[:moon:](https://www.npmjs.com/package/@extra-array/cut.min)
[:scroll:](https://unpkg.com/@extra-array/cut/)
[:newspaper:](https://nodef.github.io/extra-array/)
[:blue_book:](https://github.com/nodef/extra-array/wiki/)
> Alternatives: [cut], [cutRight].<br>
> Similar: [cut], [split], [group].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
<br>
```javascript
array.cut(x, ft);
// x: an array
// ft: test function (v, i, x)
```
```javascript
const array = require("extra-array");
var x = [1, 2, 3, 4, 5];
array.cut(x, [1, 3]);
// [ [ 1 ], [ 2, 3 ], [ 4, 5 ] ]
array.cut(x, [0, 4]);
// [ [], [ 1, 2, 3, 4 ], [ 5 ] ]
```
<br>
<br>
## References
- [Data.List.splitAt: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:splitAt)
- [numpy.split: Python](https://docs.scipy.org/doc/numpy/reference/generated/numpy.split.html)
[cut]: https://github.com/nodef/extra-array/wiki/cut
[cutRight]: https://github.com/nodef/extra-array/wiki/cutRight
[split]: https://github.com/nodef/extra-array/wiki/split
[group]: https://github.com/nodef/extra-array/wiki/group