My first program in Elixir
I ported my program for showing concurrency from Erlang to Elixir. I guess this is still not Idiomatic Elixir. 😅
defmodule Con1 do
def log(p, i) when rem(i, 3000) == 0 do
IO.puts "#{p} #{i}"
end
def log(_, _) do
:ok
end
def cnt(_, 0) do
:ok
end
def cnt(p, i) do
log(p, i)
cnt(p, i - 1)
end
def par_cnt(0) do
:ok
end
def par_cnt(n) do
spawn fn() -> cnt(n, 3000000) end
par_cnt(n - 1)
end
end