'parallel' proves array bounds
This commit is contained in:
parent
f12a0820e0
commit
6470bd8f87
3 changed files with 107 additions and 14 deletions
24
tests/parallel/tforstmt.nim
Normal file
24
tests/parallel/tforstmt.nim
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
discard """
|
||||
output: '''3
|
||||
4
|
||||
5
|
||||
6
|
||||
7'''
|
||||
sortoutput: true
|
||||
"""
|
||||
|
||||
import threadpool, math
|
||||
|
||||
proc p(x: int) =
|
||||
echo x
|
||||
|
||||
proc testFor(a, b: int; foo: var openArray[int]) =
|
||||
parallel:
|
||||
for i in max(a, 0) .. min(b, foo.len-1):
|
||||
spawn p(foo[i])
|
||||
|
||||
var arr = [0, 1, 2, 3, 4, 5, 6, 7]
|
||||
|
||||
testFor(3, 10, arr)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue