Create by https://gist.github.com/CaiJingLong/a299d15b92edc2d09a8a06cf6dd5a1b0
Last active
March 10, 2020 03:02
-
-
Save CaiJingLong/9fad35845c0ccc0752580baafac1bb48 to your computer and use it in GitHub Desktop.
range like python for dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
print(range(100, start: 1, step: 7)); | |
} | |
Iterable<int> range(int end, {int start = 0, int step = 1}) sync* { | |
assert(step >= 1); | |
int r = start; | |
while (r < end) { | |
yield r; | |
r += step; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment