Skip to content

Commit b8352dc

Browse files
committed
Edit listRangeBy() function to allow for decrementing step functions
1 parent fe9572d commit b8352dc

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

source/lib.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* lib.js
66
*
7-
* Core functions for lazy-linked-list.
7+
* Core functions for lazy-linked-lists.
88
* @license ISC
99
*/
1010

@@ -57,12 +57,11 @@ export const listRange = (start, end) => listRangeBy(start, end, (x => x + 1));
5757
*/
5858
export const listRangeBy = (start, end, step) => {
5959
if (start === end) { return list(start); }
60-
if (start > end) { return emptyList; }
6160
let x = start;
6261
const xs = list(x);
6362
const listGenerator = function* () {
6463
x = step(x);
65-
while (x < end) {
64+
while (start < end ? x < end : x > end) {
6665
yield list(x);
6766
x = step(x);
6867
}

0 commit comments

Comments
 (0)