t17460.nim 486 B

1234567891011121314151617181920
  1. discard """
  2. cmd: "nim check $options $file"
  3. errormsg: "tuple expected for tuple unpacking, but got 'array[0..2, int]'"
  4. """
  5. iterator xclusters*[T](a: openArray[T]; s: static[int]): array[s, T] {.inline.} =
  6. var result: array[s, T] # iterators have no default result variable
  7. var i = 0
  8. while i < len(a):
  9. for j, x in mpairs(result):
  10. x = a[(i + j) mod len(a)]
  11. yield result
  12. inc(i)
  13. proc m =
  14. for (i, j, k) in xclusters([1, 2, 3, 4, 5], 3):
  15. echo i, j, k
  16. m()