This will help you understand that code better:
    
    
    import strformat, typetraits
    let r = [0 .. 3, 0 .. 3]
    echo fmt"r = {r}, of type `{$r.type}'"
    
    for x, y  in r:
      echo fmt"x = {x}, of type `{$x.type}'"
      echo fmt"y = {y}, of type `{$y.type}'"
    
    
    Run

Output:
    
    
    r = [(a: 0, b: 3), (a: 0, b: 3)], of type `array[0..1, HSlice[system.int, 
system.int]]'
    x = 0, of type `range 0..1(int)'
    y = (a: 0, b: 3), of type `HSlice[system.int, system.int]'
    x = 1, of type `range 0..1(int)'
    y = (a: 0, b: 3), of type `HSlice[system.int, system.int]'
    
    
    Run

This is probably what you wanted:
    
    
    import strformat, typetraits
    for x in 0 .. 3:
      for y in 0 .. 3:
        echo fmt"x = {x}, of type `{$x.type}', y = {y}, of type `{$y.type}'"
    
    
    Run

Outputs:
    
    
    x = 0, of type `int', y = 0, of type `int'
    x = 0, of type `int', y = 1, of type `int'
    x = 0, of type `int', y = 2, of type `int'
    x = 0, of type `int', y = 3, of type `int'
    x = 1, of type `int', y = 0, of type `int'
    x = 1, of type `int', y = 1, of type `int'
    x = 1, of type `int', y = 2, of type `int'
    x = 1, of type `int', y = 3, of type `int'
    x = 2, of type `int', y = 0, of type `int'
    x = 2, of type `int', y = 1, of type `int'
    x = 2, of type `int', y = 2, of type `int'
    x = 2, of type `int', y = 3, of type `int'
    x = 3, of type `int', y = 0, of type `int'
    x = 3, of type `int', y = 1, of type `int'
    x = 3, of type `int', y = 2, of type `int'
    x = 3, of type `int', y = 3, of type `int'
    
    
    Run

Reply via email to