@@ -69,9 +69,9 @@ var arr = ndarray2array( y );
69
69
The function accepts the following arguments:
70
70
71
71
- ** x** : input [ ndarray] [ @stdlib/ndarray/ctor ] .
72
- - ** options** : function options.
72
+ - ** options** : function options _ (optional) _ .
73
73
- ** predicate** : predicate function.
74
- - ** thisArg** : predicate function execution context.
74
+ - ** thisArg** : predicate function execution context _ (optional) _ .
75
75
76
76
The function accepts the following options:
77
77
@@ -113,6 +113,41 @@ var arr = ndarray2array( y );
113
113
// returns [ 8.0, 9.0, 10.0 ]
114
114
```
115
115
116
+ To set the ` predicate ` function execution context, provide a ` thisArg ` .
117
+
118
+ <!-- eslint-disable no-invalid-this, max-len -->
119
+
120
+ ``` javascript
121
+ var Float64Array = require ( ' @stdlib/array/float64' );
122
+ var ndarray = require ( ' @stdlib/ndarray/ctor' );
123
+ var ndarray2array = require ( ' @stdlib/ndarray/to-array' );
124
+
125
+ function predicate ( z ) {
126
+ this .count += 1 ;
127
+ return z <= 6.0 ;
128
+ }
129
+
130
+ var buffer = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 ] );
131
+ var shape = [ 2 , 3 ];
132
+ var strides = [ 6 , 1 ];
133
+ var offset = 1 ;
134
+
135
+ var x = ndarray ( ' float64' , buffer, shape, strides, offset, ' row-major' );
136
+ // returns <ndarray>
137
+
138
+ var ctx = {
139
+ ' count' : 0
140
+ };
141
+ var y = reject ( x, predicate, ctx );
142
+ // returns <ndarray>
143
+
144
+ var arr = ndarray2array ( y );
145
+ // returns [ 8.0, 9.0, 10.0 ]
146
+
147
+ var count = ctx .count ;
148
+ // returns 6
149
+ ```
150
+
116
151
The ` predicate ` function is provided the following arguments:
117
152
118
153
- ** value** : current array element.
0 commit comments