Erlang does not create multiple OS processes. It all runs in a single OS process which will create multiple schedulers which are native OS threads. Just wanted to correct that statement because it was slightly off...
i am quite new to Elixir, but think the problem in the pmap function is related to the fact that your are not pattern mathing against messages you want to receive. earlier in the tutoral you say, that send should return tuple like {:hello, "hello"} which you could pattern-match against {:hello, str}. in the pmap function your are not sending a tuple back - you are just sending a result of the funtion call. and you are trying to match that against {pid, result} which seems to fail. here is a corrected version that worked for me: def pmap(list,func) do me = self list |> Enum.map(fn(elem) -> spawn(fn -> send(me,{:result, func.(elem)}) end ) end ) |> Enum.map(fn(pid) -> receive do {:result, result} -> result end end) end again, im new to this, so sorry if i am saying something stupid. just trying to learn new stuff :)
The pmap function didn't worked at IEx (just runs for ever) because the IEx has a different PID itself. Use "$ elixir misc.exs" and it will work just fine.
One thing I really hate about a lot of tech talks. Sounds like he wrote down a list of topics to talk about rather than really designing the presentation- writing a presentation should take more time than writing an article on the topic, not less. It's a fundamentally different activity than casually taking a few minutes at work to show a coworker the ropes with something. At least he didn't just make 45 minutes worth of powerpoint slides and read them.
Erlang does not create multiple OS processes. It all runs in a single OS process which will create multiple schedulers which are native OS threads.
Just wanted to correct that statement because it was slightly off...
In your pmap function the send statement should be 'send(me, {self, func.(elem)})'. That will work.
i love this language :) ! The inline tests + documentation are a beast! Wish i started learning it sooner :))
i am quite new to Elixir, but think the problem in the pmap function is related to the fact that your are not pattern mathing against messages you want to receive. earlier in the tutoral you say, that send should return tuple like {:hello, "hello"} which you could pattern-match against {:hello, str}. in the pmap function your are not sending a tuple back - you are just sending a result of the funtion call. and you are trying to match that against {pid, result} which seems to fail. here is a corrected version that worked for me:
def pmap(list,func) do
me = self
list
|> Enum.map(fn(elem) -> spawn(fn -> send(me,{:result, func.(elem)}) end ) end )
|> Enum.map(fn(pid) ->
receive do
{:result, result} -> result
end
end)
end
again, im new to this, so sorry if i am saying something stupid. just trying to learn new stuff :)
this really is somewhat similar to prolog and to another language I had back at the university, called maude. very nice
which editor you use?
Sublime Text 3 with the Twilight color scheme
Pete Broderick thank you
Ronierison Maciel you're very welcome
Pete Broderick grateful
The pmap function didn't worked at IEx (just runs for ever) because the IEx has a different PID itself. Use "$ elixir misc.exs" and it will work just fine.
haha, even the guy who is doing the lecture can't get the syntax right :D
Feels a bit like you sat with it for an hour and then wrote the talk. Spend a bit more time before you do presentations in the future.
One thing I really hate about a lot of tech talks. Sounds like he wrote down a list of topics to talk about rather than really designing the presentation- writing a presentation should take more time than writing an article on the topic, not less. It's a fundamentally different activity than casually taking a few minutes at work to show a coworker the ropes with something. At least he didn't just make 45 minutes worth of powerpoint slides and read them.