Skip to content

Commit eae6fd5

Browse files
committed
Refactor to use zero-based indexing
1 parent 8744ffa commit eae6fd5

5 files changed

Lines changed: 26 additions & 26 deletions

File tree

lib/node_modules/@stdlib/iter/to-array-view-right/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ The invoked function is provided three arguments:
122122

123123
- `value`: iterated value
124124
- `index`: destination index (zero-based)
125-
- `n`: iteration count (one-based)
125+
- `n`: iteration index (zero-based)
126126

127127
```javascript
128128
var Uint8Array = require( '@stdlib/array/uint8' );
129129
var array2iterator = require( '@stdlib/array/to-iterator' );
130130

131131
function fcn( v, i, n ) {
132-
return v * n;
132+
return v * (n+1);
133133
}
134134

135135
var iter = array2iterator( [ 1, 2, 3, 4 ] );
@@ -190,7 +190,7 @@ var randu = require( '@stdlib/random/iter/randu' );
190190
var iterator2arrayviewRight = require( '@stdlib/iter/to-array-view-right' );
191191

192192
function scale( v, i, n ) {
193-
return v * n * 10.0;
193+
return v * (n+1) * 10.0;
194194
}
195195

196196
// Create an iterator for generating uniformly distributed pseudorandom numbers:

lib/node_modules/@stdlib/iter/to-array-view-right/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
- value: iterated value
99
- index: destination index (zero-based)
10-
- n: iteration count (one-based)
10+
- n: iteration index (zero-based)
1111

1212
Iteration stops when an output array view is full or an iterator finishes;
1313
whichever comes first.

lib/node_modules/@stdlib/iter/to-array-view-right/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var randu = require( '@stdlib/random/iter/randu' );
2323
var iterator2arrayviewRight = require( './../lib' );
2424

2525
function scale( v, i, n ) {
26-
return v * n * 10.0;
26+
return v * (n+1) * 10.0;
2727
}
2828

2929
// Create an iterator for generating uniformly distributed pseudorandom numbers:

lib/node_modules/@stdlib/iter/to-array-view-right/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function iterator2arrayviewRight( iterator, out ) {
145145
i -= 1;
146146
v = iterator.next();
147147
if ( hasOwnProp( v, 'value' ) ) {
148-
out[ i ] = fcn.call( thisArg, v.value, i, end-i );
148+
out[ i ] = fcn.call( thisArg, v.value, i, end-i-1 );
149149
}
150150
if ( v.done ) {
151151
break;

lib/node_modules/@stdlib/iter/to-array-view-right/test/test.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
984984
t.end();
985985

986986
function scale( v, i, n ) {
987-
return v * n;
987+
return v * (n+1);
988988
}
989989
});
990990

@@ -1007,7 +1007,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
10071007
t.end();
10081008

10091009
function scale( v, i, n ) {
1010-
return v * n;
1010+
return v * (n+1);
10111011
}
10121012
});
10131013

@@ -1030,7 +1030,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
10301030
t.end();
10311031

10321032
function scale( v, i, n ) {
1033-
return v * n;
1033+
return v * (n+1);
10341034
}
10351035
});
10361036

@@ -1053,7 +1053,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
10531053
t.end();
10541054

10551055
function scale( v, i, n ) {
1056-
return v * n;
1056+
return v * (n+1);
10571057
}
10581058
});
10591059

@@ -1076,7 +1076,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
10761076
t.end();
10771077

10781078
function scale( v, i, n ) {
1079-
return v * n;
1079+
return v * (n+1);
10801080
}
10811081
});
10821082

@@ -1099,7 +1099,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
10991099
t.end();
11001100

11011101
function scale( v, i, n ) {
1102-
return v * n;
1102+
return v * (n+1);
11031103
}
11041104
});
11051105

@@ -1122,7 +1122,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
11221122
t.end();
11231123

11241124
function scale( v, i, n ) {
1125-
return v * n;
1125+
return v * (n+1);
11261126
}
11271127
});
11281128

@@ -1145,7 +1145,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
11451145
t.end();
11461146

11471147
function scale( v, i, n ) {
1148-
return v * n;
1148+
return v * (n+1);
11491149
}
11501150
});
11511151

@@ -1168,7 +1168,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
11681168
t.end();
11691169

11701170
function scale( v, i, n ) {
1171-
return v * n;
1171+
return v * (n+1);
11721172
}
11731173
});
11741174

@@ -1191,7 +1191,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
11911191
t.end();
11921192

11931193
function scale( v, i, n ) {
1194-
return v * n;
1194+
return v * (n+1);
11951195
}
11961196
});
11971197

@@ -1214,7 +1214,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
12141214
t.end();
12151215

12161216
function scale( v, i, n ) {
1217-
return v * n;
1217+
return v * (n+1);
12181218
}
12191219
});
12201220

@@ -1237,7 +1237,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
12371237
t.end();
12381238

12391239
function scale( v, i, n ) {
1240-
return v * n;
1240+
return v * (n+1);
12411241
}
12421242
});
12431243

@@ -1260,7 +1260,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
12601260
t.end();
12611261

12621262
function scale( v, i, n ) {
1263-
return v * n;
1263+
return v * (n+1);
12641264
}
12651265
});
12661266

@@ -1283,7 +1283,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
12831283
t.end();
12841284

12851285
function scale( v, i, n ) {
1286-
return v * n;
1286+
return v * (n+1);
12871287
}
12881288
});
12891289

@@ -1306,7 +1306,7 @@ tape( 'the function supports providing a callback to be invoked for each iterate
13061306
t.end();
13071307

13081308
function scale( v, i, n ) {
1309-
return v * n;
1309+
return v * (n+1);
13101310
}
13111311
});
13121312

@@ -1367,7 +1367,7 @@ tape( 'the function stops filling an array-like object once an iterator ends (ca
13671367
t.end();
13681368

13691369
function scale( v, i, n ) {
1370-
return v * n;
1370+
return v * (n+1);
13711371
}
13721372
});
13731373

@@ -1390,7 +1390,7 @@ tape( 'the function stops filling an array-like object once an iterator ends (va
13901390
t.end();
13911391

13921392
function scale( v, i, n ) {
1393-
return v * n;
1393+
return v * (n+1);
13941394
}
13951395
});
13961396

@@ -1418,7 +1418,7 @@ tape( 'the function supports specifying the evaluation context of a provided cal
14181418

14191419
function scale( v, i, n ) {
14201420
this.count += 1; // eslint-disable-line no-invalid-this
1421-
return v * n;
1421+
return v * (n+1);
14221422
}
14231423
});
14241424

@@ -1446,7 +1446,7 @@ tape( 'the function supports specifying the evaluation context of a provided cal
14461446

14471447
function scale( v, i, n ) {
14481448
this.count += 1; // eslint-disable-line no-invalid-this
1449-
return v * n;
1449+
return v * (n+1);
14501450
}
14511451
});
14521452

@@ -1474,7 +1474,7 @@ tape( 'the function supports specifying the evaluation context of a provided cal
14741474

14751475
function scale( v, i, n ) {
14761476
this.count += 1; // eslint-disable-line no-invalid-this
1477-
return v * n;
1477+
return v * (n+1);
14781478
}
14791479
});
14801480

0 commit comments

Comments
 (0)