Iterator & Incrementor (types) in javascript

Allow Iterator & Incrementor (types) in javascript

[ iter|inc ] [variable-name] = [ min:max[:step] ]   

/* max param is bounds-inclusive; step-size can be 
++--step or step++-- 
and size defaults to 1 */

Example

let a = 0:10  // iter
let b = 0:10:1  // ++b
let c = 0:10:++1  // ++c

mat3[a] = mat1[b] * mat2[c] * mat3[a]
mat3[a][b][c] = mat1[a][b][c] * mat2[a][b][c] * mat3[a][b][c] // Computes right-most, first

let c2 = 0:10:1++    // c2++
let d = 10:1:--1     // --d

mat1[d] = d + 4

while(d) { // cast iter to inc (type)
    mat1[d] = d + 4
}

Have you seen the Number.range proposal?

1 Like