tforstmt.nim 323 B

1234567891011121314151617181920212223242526
  1. discard """
  2. output: '''3
  3. 4
  4. 5
  5. 6
  6. 7'''
  7. sortoutput: true
  8. """
  9. import threadpool, os
  10. proc p(x: int) =
  11. os.sleep(100 - x*10)
  12. echo x
  13. proc testFor(a, b: int; foo: var openArray[int]) =
  14. parallel:
  15. for i in max(a, 0) .. min(b, foo.high):
  16. spawn p(foo[i])
  17. var arr = [0, 1, 2, 3, 4, 5, 6, 7]
  18. testFor(3, 10, arr)