Closed kai-tub closed 3 years ago
Good catch. That would be grand @kai-tub, thanks!
One question, should we remove the code for fewer than 4 elements?
def spawn(n) when n < 4 do
calc_product(n)
end
I don't think there is any reason to keep the function, as chunk_every
will just return a list containing a single list with fewer than 4 elements. Or do we want to change the number to something like 10 to show of the when
keyword and argue that splitting creates more overhead?
Thanks again @kai-tub 🥇
The code uses
chunk_every
which returns a list of lists withn
elements per list. (The last chunk may contain fewer elements).So AFAIK, this block should be changed. The number of lists/resulting processes will be
n % 4
ifn % 4 == 0
elsen % 4 + 1
.Otherwise, thanks for the great introduction! :)
PS: I am happy to rewrite it and make a PR if you like.