-
-
Save fishcakez/ae40d2667ea9d414caf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def concurrent_factorial(range, worker_pool_by_nodenames \\ worker_pool_by_nodenames) | |
def concurrent_factorial(%Range{first: start, last: finish}, worker_pool_by_nodenames) do | |
pmap(split_range_of_numbers(start..finish), fn(range) -> range |> Enum.reduce(&(&1*&2)) end, worker_pool_by_nodenames) |> | |
Enum.reduce(&(&1*&2)) | |
end | |
def concurrent_factorial(n, worker_pool_by_nodenames) when is_integer(n) and n > 0 do | |
concurrent_factorial(1..n, worker_pool_by_nodenames) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment