Ad
Code
Diff
  • function* generateInterval(a = 0, b = NaN, c = 1) {
        if (isNaN(b)) [a, b] = [0, a];
        for (const s = Math.sign(c); (b - a) * s >= 0; a += c)
            yield a;
    }
    
    // Python range() API
    function* range(a = 0, b = NaN, c = 1) {
        if (isNaN(b)) [a, b] = [0, a];
        for (const s = Math.sign(c); (b - a) * s > 0; a += c)
            yield a;
    }
    
    • function* generateInterval(a,b,c){for(;c>0?a<=b:a>=b;a+=c)yield a}
    • function* generateInterval(a = 0, b = NaN, c = 1) {
    • if (isNaN(b)) [a, b] = [0, a];
    • for (const s = Math.sign(c); (b - a) * s >= 0; a += c)
    • yield a;
    • }
    • // Python range() API
    • function* range(a = 0, b = NaN, c = 1) {
    • if (isNaN(b)) [a, b] = [0, a];
    • for (const s = Math.sign(c); (b - a) * s > 0; a += c)
    • yield a;
    • }