Intro to Elixir

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

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...

mattwidmann
Автор

In your pmap function the send statement should be 'send(me, {self, func.(elem)})'. That will work.

timatinterwebs
Автор

i love this language :) ! The inline tests + documentation are a beast! Wish i started learning it sooner :))

aion
Автор

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 :)

przadka
Автор

this really is somewhat similar to prolog and to another language I had back at the university, called maude. very nice

victorb
Автор

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.

fernandoschuindt
Автор

haha, even the guy who is doing the lecture can't get the syntax right :D

spnteam
Автор

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.

kalit