Question:I’m trying to parallelize this function by using @async @sync
Threads.nthreads()and they are 4
Answer:Your code is sequential, as you have a recursive dependence in
res– so trying to parallelize it is both not possible and can lead to incorrect results. Essentially your code tries to re-implement
foldrin a less efficient and non-generic way:
If you have better answer, please add a comment about this, thank you!