File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ treduce(+, data)
136
136
using Base. Threads: @threads
137
137
data = rand (10 )
138
138
139
- @threads for i in 1 : 10
139
+ @threads for i in eachindex (data)
140
140
data[i] = calc (i)
141
141
end
142
142
```
@@ -146,21 +146,21 @@ end
146
146
using OhMyThreads: @tasks
147
147
data = rand (10 )
148
148
149
- @tasks for i in 1 : 10
149
+ @tasks for i in eachindex (data)
150
150
data[i] = calc (i)
151
151
end
152
152
153
153
# or
154
154
using OhMyThreads: tforeach
155
155
156
- tforeach (data) do i
156
+ tforeach (eachindex ( data) ) do i
157
157
data[i] = calc (i)
158
158
end
159
159
160
160
# or
161
161
using OhMyThreads: tmap!
162
162
163
- tmap! (data, data) do i # this kind of aliasing is fine
163
+ tmap! (data, eachindex ( data)) do i
164
164
calc (i)
165
165
end
166
166
```
175
175
using Base. Threads: @threads
176
176
177
177
data = Vector {Float64} (undef, 10 )
178
- @threads for i in 1 : 10
178
+ @threads for i in eachindex (data)
179
179
data[i] = calc (i)
180
180
end
181
181
```
You can’t perform that action at this time.
0 commit comments