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