Last active
August 29, 2015 14:19
-
-
Save pmarreck/e139d9522098b82d2816 to your computer and use it in GitHub Desktop.
so this compiled. interesting...
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(n) when is_integer(n) and n > 0 do | |
concurrent_factorial(1..n) | |
end | |
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) |> | |
# one more reduction... | |
Enum.reduce(&(&1*&2)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment