Spinors

Spinors (Pronounced "Spinners") are complex vector space spin groups whose rotational half-period exceeds that of the standard half-circle

Spinors are used, among other things, to model the spin of subatomic particles and electrons

Spinors are best represented in javascript, as one or more nested for-loops, within a conditional (or indefinite!) while-loop


let a = [ // var k
    [ // var j
        [0,1,2,3,4] // var i
    ],
    [
        [5,6,7,8,9]
    ],
]
let b = 0
while(1){ // always true
    for(var k=0;k<2;k++){ // turn (3)
        for(var j=0;j<1;j++){ // turn (2)
            for(var i=0;i<5;i++){ // turn (1)
                b = b + 1 - 1
                a[k][j][i] = b++
            }
        }
    }
    break // formalizes the mobius completion
}

I propose to make the representation of these -- or other nested and indefinite loops, more compact



mobius-spinor-loop(var i=0,j=0,k=0; i<5,j<1,k<2; k++,j++,i++, break){ // Incrementing order is important!
    b = b + 1 - 1
    a[k][j][i] = b++
}
1 Like

Well, there are already iterators, so you could just write:

const range = (start, end) => function*() { for(let i = start; i < end; i++) yield i; };
function* nested (outer, ...inner) {
  if(!outer) { yield []; return; }
  for(const v of outer()) 
    for(const i of nested(...inner))
      yield [v, ...i];
}

for(const [i, j, k] of nested(range(0, 5), range(0, 1), range(0, 5))) {
  // ...
}

Why do you see the need for a new keyword mobius-spinor-loop, if this can easily already be achieved quite elegantly with existing language constructs, and is probably not used that often?

Also known as power loops. For good reason, these never caught on.