<div dir="ltr"><p>Hi there -</p><p>Apart from the atom-vs-Variable issue, I think you got your recursion wrong.</p><p>   [M1 | chunks(T1,
P1)]</p><p>doesn't make too much sense (that I can see) - especially the "recurse with P1 for Lst" part.</p><p>I think you mean either</p><p>  chunks(T1, [M1|Lst])</p><p>for a tail recursive loop, or</p><p>  chunks("") -> [];</p><p>  chunks(Str) -> ..., [M1 | chunks(T1)]</p><p>for "normal" recursion on the rest. At present, you code looks like a confusion of the two (apart from the Lst/P1 difference).</p><p><br></p><p>Regards, and have fun on the learning curve,<br></p><p>Erik<br></p><p><br></p>
<div class="gmail_quote">Den 06/11/2014 20.27 skrev "Fred Youhanaie" <<a href="mailto:fly@anydata.co.uk" target="_blank">fly@anydata.co.uk</a>>:<br type="attribution"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
and of course the same goes for lst in chunks/2 :)<br>
<br>
On 06/11/14 19:09, James Aimonetti wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<br>
str should be Str. Variables start with a capital letter.<br>
<br>
Le 2014-11-06 10:56, Charles Hixson a écrit :<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Given the routine: -module(chunks). -export([chunks/1]).<br>
chunks(str)-> chunks(str, []).<br>
<br>
chunks("", lst)-> list:reverse(lst); chunks(str, lst)-> P1 =<br>
"^([[:alnum:]]+|[[:space:]]+|[<u></u>[:punct:]]+|[[:cntrl:]]+|.)", [[],<br>
M1, T1] = re:split(str, P1, [{return, list}]), [M1 | chunks(T1,<br>
P1)].<br>
<br>
and the shell: 47> c(chunks). {ok,chunks}<br>
<br>
Why do I get: 49> chunks:chunks("Able was I ere I saw Elba."). **<br>
exception error: no function clause matching chunks:chunks("Able<br>
was I ere I saw Elba.") (chunks.erl, line 15) (Well, forget the<br>
like 15.  I took out a bunch of comments.)<br>
</blockquote></blockquote>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</blockquote></div>
</div>