1function range(start, end) {
2 /* generate a range : [start, start+1, ..., end-1, end] */
3 var len = end - start + 1;
4 var a = new Array(len);
5 for (let i = 0; i < len; i++) a[i] = start + i;
6 return a;
7}
1function* range(start=0, end=null, step=1) {
2 if (end == null) {
3 end = start;
4 start = 0;
5 }
6
7 for (let i=start; i < end; i+=step) {
8 yield i;
9 }
10}
11