Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/ndarray-foreach
Scans an ndarray
https://github.com/mikolalysenko/ndarray-foreach
Last synced: 7 days ago
JSON representation
Scans an ndarray
- Host: GitHub
- URL: https://github.com/mikolalysenko/ndarray-foreach
- Owner: mikolalysenko
- Created: 2017-04-24T13:19:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-24T13:21:28.000Z (over 7 years ago)
- Last Synced: 2024-12-16T22:35:15.141Z (10 days ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ndarray-foreach
===============
Loop over an ndarray, convenience method using cwise.# Install
```
npm i ndarray-foreach
```# Example
```javascript
var ndarray = require('ndarray')
var ndforeach = require('ndarray-foreach')var data = ndarray([
0, 1, 2,
3, 4, 5,
6, 7, 8
], [3, 3])ndforeach(data, function (i, a) {
console.log(i, a)
})
```### Output:
```
[ 0, 0 ] 0
[ 0, 1 ] 1
[ 0, 2 ] 2
[ 1, 0 ] 3
[ 1, 1 ] 4
[ 1, 2 ] 5
[ 2, 0 ] 6
[ 2, 1 ] 7
[ 2, 2 ] 8
```# API
### `require('ndarray-foreach')(array, f(index, v))`
Scans an ndarray.* `array` is an ndarray
* `f(index, v)` is a visitor function# License
(c) 2017 Mikola Lysenko, MIT License