Error reported when using pmap
Arbow
avindev@REDACTED
Wed Aug 30 10:22:28 CEST 2006
Hi All:
I am new in Erlang, and try the pmap at
http://www.erlang.org/ml-archive/erlang-questions/200606/msg00187.html:
In file test.erl:
-module(test).
-export([pmap/2]).
pmap(F, L) ->
S = self(),
Pids = list:map(
fun(I) ->
spawn(
fun() ->
do_f(S, F, I)
end)
end, L),
gather(Pids).
gather([H|T]) ->
receive
{H, Ret} -> [Ret|gather(T)]
end;
gather([]) ->
[].
do_f(Parent, F, I) ->
io:format("Receive item ~w~n", [I]),
Parent ! {self(), (catch F(I))}.
In file testmain.erl:
-module(testmain).
-export([test3/0]).
test3() ->
MyList = [1,2,3,4,5,6,7,8,9,10],
lists:map(fun(I) -> I*2 end, MyList).
when I execute " testmain:test3(). ", I get errors:
=ERROR REPORT==== 30-Aug-2006::16:21:51 ===
Error in process <0.36.0> on node 'Erlide_2960df@REDACTED' with exit value:
{undef,[{testmain,test3,[]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
** exited: {undef,[{testmain,test3,[]},
{erl_eval,do_apply,5},
{shell,exprs,6},
{shell,eval_loop,3}]} **
Anyone could help me? Thanks.
Best regards.
Arbow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060830/d53465ca/attachment.htm>
More information about the erlang-questions
mailing list