Skip to content

Instantly share code, notes, and snippets.

@pmarreck
Last active August 29, 2015 14:19
Show Gist options
  • Save pmarreck/e139d9522098b82d2816 to your computer and use it in GitHub Desktop.
Save pmarreck/e139d9522098b82d2816 to your computer and use it in GitHub Desktop.
so this compiled. interesting...
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