Yes, I actually started with a macro that produces a variadic zip. It's still 
untouched in my code.

The reason is that the following does not compile, error is `Error: iterator 
within for loop context expected`
    
    
    template zipTest(arguments: varargs[untyped]): untyped =
      iterator zipZipZip(a: seq[int], b: seq[bool], c: seq[int], d: 
seq[float]): (int, bool, int, float) =
        let size0 = a.len
        for i in 0..<size0:
          yield (a[i], b[i], c[i], d[i])
      
      zipZipZip(arguments)
    
    for a, b, c, d in zipTest(@[1,10,15], @[false, false, true], @[3,2,1], 
@[4.0,5.0,6.0]):
      echo (a,b,c,d)
    

I don't see a way to support any number of sequences with any kind of types 
without a wrapper that:
    

  * creates the proper iterator,
  * call it after,



since we can't create an iterator within a for loop call

Bonus, I just added forEach expressions. It works if there is a return value at 
each step. I still have to figure out conditional returns.

Also we have to use parenthesis in expression mode.
    
    
    import loopfusion
    
    let a = @[1, 2, 3]
    let b = @[4, 5, 6]
    
    
    let c = forEach(x in a, y in b):
      x + y
    
    doAssert c == @[5, 7, 9]
    

Reply via email to