I'm sorry, you code has so many errors.<br>I think you'd better look at the book <programming erlang >, and the erlang referance manual.<br><br>the fllow code snips is my code, but I don't know If it's your need. I hope it's useful for you:<br>
%%%%%%%%%%%%%%%%%%%%%%<br>-module(serec).<br>-export([start/0, get_squarer/2]).<br> <br>seq(Start, End) -> seq(Start, End, []).<br><br>seq(Start, End, Acc) when Start =< End -><br> seq(Start, End-1, [End|Acc]);<br>
seq(_, _, Acc) -><br> Acc.<br><br>squarer() -><br> receive<br> {From, N} when N > 7 -><br> From ! {self(), [X*X || X <- seq(1, 7)]},<br> squarer();<br> {From, N} -><br> From ! {self(), [X*X || X <- seq(1, N)]},<br>
squarer();<br> Other -><br> Other<br> end.<br><br>%% @spec squarer() -> Pid<br>%% @doc create the squarer process<br>start() -><br> spawn(fun squarer/0).<br><br>%% @spec get_squarer(Pid, N) -> Result<br>
%% @doc get the result form squarer process<br>get_squarer(Pid, N) when is_pid(Pid) -><br> Pid ! {self(), N},<br> receive<br> {Pid, Result} -><br> Result;<br> Other -><br> Other<br>
end.<br>%%%%%%%%%%%%%%%%%%%<br><br>usage:<br>4> c(serec).<br>{ok,serec}<br>5> Pid = serec:start().<br><0.49.0><br>6> serec:get_squarer(Pid, 3).<br>[1,4,9]<br>7> serec:get_squarer(Pid, 4).<br>[1,4,9,16]<br>
8> serec:get_squarer(Pid, 5).<br>[1,4,9,16,25]<br>9> serec:get_squarer(Pid, 10).<br>[1,4,9,16,25,36,49]<br><br><br><div class="gmail_quote">2008/7/3 not norwegian swede <<a href="mailto:notnorwegian@yahoo.se">notnorwegian@yahoo.se</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
im using:<br><a href="http://www.erlang.org/doc/reference_manual/part_frame.html" target="_blank">http://www.erlang.org/doc/reference_manual/part_frame.html</a><br>but cant really figure it out. i didnt expect this to work but compiled anyway:<br>
2> c("c:/Program Files/erl5.6.2/usr/serec", [{outdir, "c:/Program Files/erl5.6.2/usr/"}]).<br>c:/Program Files/erl5.6.2/usr/serec.erl:2: function squarer/1 undefined<br>c:/Program Files/erl5.6.2/usr/serec.erl:2: function squarer2/1 undefined<br>
c:/Program Files/erl5.6.2/usr/serec.erl:23: premature end<br>error<br>3> <br><br><br>obv this is just a toy program but say I have a function that squares the integers of a list from 1 to the send parameter.<br>so i want to send a message to that function.<br>
<br><br>-module(serec).<br>-export([seq/2,squarer/1,squarer2/1]).<br> <br>seq(Start, End) -> seq(Start, End, []).<br><br>seq(Start, End, Acc) when Start
=< End -><br> seq(Start, End-1, [End|Acc]);<br>seq(_, _, Acc) -><br> Acc.<br><br>squarer(X) -><br> receive<br> Pattern [when Pattern > 7] -><br> [X*X || X <- [seq(1, 7]];<br> end<br>
<br>squarer2(X) -><br> receive<br> when X > 7 -> [X*X || X <- [seq(1, 7]];<br> end<br><br>squarer(X) ! 2+6<br><br></td></tr></tbody></table><br>
<hr size="1">
Låna pengar utan säkerhet.<br>
<a href="http://www.kelkoo.se/c-100390123-lan-utan-sakerhet.html?partnerId=96915014" target="_blank">Sök och jämför lån hos Kelkoo.</a><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>