Skip to content

Instantly share code, notes, and snippets.

@ohta-rh
Last active November 11, 2019 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohta-rh/254b84ddf666947e92405abeeefc2dc1 to your computer and use it in GitHub Desktop.
Save ohta-rh/254b84ddf666947e92405abeeefc2dc1 to your computer and use it in GitHub Desktop.
Elixirでコアをつかいきってみる
defmodule Multicore do
@moduledoc """
Documentation for Multicore.
"""
@doc """
Hello world.
## Examples
iex> Multicore.hello()
:world
"""
def sum(from, to) do
Enum.reduce(from..to, fn x, acc -> x+acc end) |> IO.puts
end
def main do
0..1000
|> Enum.map(fn _ -> Task.async(fn -> sum(1, 100000) end) end)
|> Enum.map(fn x -> Task.await(x) end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment