Hi Sid,<div><br></div><div>The final argument to spawn is a list of arguments. In your case, the function format_temps takes one argument, which happens to be a list.</div><div><br></div><div>Therefore, you should use a list containing a list as the final argument to spawn, as in:</div>
<div><br></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">spawn(?MODULE, format_temps, [ [{moscow,{f,-40}}, {bangalore,{f,40}}, {wellington, {c,24}}] ])</span><br>
<br><div class="gmail_quote">On Wed, Jun 22, 2011 at 11:03 AM, Sid Carter <span dir="ltr"><<a href="mailto:sidcarter@gmail.com">sidcarter@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>
            <div>
                <span>Hi Folks,</span><span></span></div><div><span><br></span></div><div><span>New to Erlang and playing with code and trying to learn erlang.</span></div><div><span><br></span></div><div><span>I have been reading the getting started guide and trying this code (on Mac OS X with erlang from MacPorts):</span></div>
<div><span><br></span></div><div><span><div>-module(first).</div><div>% call would look like format_temps([{moscow,{f,-40}}, {bangalore,{f,40}}, {wellington, {c,24}}]).</div><div>-export([format_temps/1, start/0]).</div><div>
format_temps([]) -></div><div><span style="white-space:pre-wrap">        </span>ok;</div><div>format_temps([City|Rest]) -></div><div><span style="white-space:pre-wrap">        </span>print_temp(convert_to_celsius(City)),</div><div>
<span style="white-space:pre-wrap">     </span>format_temps(Rest). </div><div>convert_to_celsius({City, {c, C}}) -></div><div><span style="white-space:pre-wrap">      </span>{City, {c, C}};</div><div>convert_to_celsius({City, {f, F}}) -></div>
<div><span style="white-space:pre-wrap">  </span>{City, {c, (F-32)*5/9}}.</div><div>print_temp({City, {c, C}}) -></div><div><span style="white-space:pre-wrap">  </span>io:format("~p has a temperature of ~w C~n",[City,C]).</div>
<div>start() -></div><div><span style="white-space:pre-wrap">      </span>Pid = spawn(?MODULE, format_temps, [{moscow,{f,-40}}, {bangalore,{f,40}}, {wellington, {c,24}}]),</div><div><span style="white-space:pre-wrap">        </span>Pid.</div>
<div><br></div><div>When I try to run:</div><div><br></div><div>first:format_temps(args).</div><div><br></div><div>I don't have any problems. I get the correct response.</div><div><br></div><div>When I try to run as:</div>
<div><br></div><div>first:start().</div><div><br></div><div>I get the following error:</div><div><br></div><div><div>Error in process <0.49.0> with exit value: {undef,[{first,format_temps,[{moscow,{f,-40}},{bangalore,{f,40}},{wellington,{c,24}}]}]}</div>
<div><br></div><div>What's wrong?</div><div><br></div><div>Thanks</div><div>Sid</div></div></span></div>
        </div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>