<div dir="ltr"><div>Hi Richard,</div><div><br></div>I'm confused by your response... is it possible to do tail-recursion in Java (and thus make iteration and recursion similar)? <div><br></div><div>I had imagined that each recursive function call in a JVM would add a frame to the stack and eventually cause an overflow.<div><br></div><div>Maybe I missed making my point. :(</div><div><br></div><div>/s<br><br>On Sunday, June 22, 2014 11:40:54 PM UTC-5, Richard A. O'Keefe wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>On 21/06/2014, at 12:58 PM, Steve Davis wrote:
<br>
<br>> It's not hard... but can be extremely expensive if it builds a call stack (e.g. Java)...
<br>
<br>Presumably "It" here refers to "recursion".
<br>
<br>Extremely expensive compared to *what*?
<br>
<br>There are problems where you could naturally use either
<br>iteration or tail recursion, and it doesn't matter which
<br>one you use because they are the same thing.
<br>
<br>And there are problems that can be expressed simply using
<br>general recursion.  For those problems, doing without it
<br>results in code that harder for people and worse for computers.
<br>
<br>There can be no problems that are easier with iteration than
<br>recursion, although there can be problems that are easier
<br>with particular *syntax*.
<br>
<br>If we are talking about "Erlang for youngsters",
<br>I wonder whether it might not be easier to teach
<br>the *use* of higher-order traversal functions than
<br>direct loops of any kind.  I remember it being
<br>*amazing* how much you could get done in APL without
<br>a loop of your own in sight.
<br>
<br>______________________________<wbr>_________________
<br>erlang-questions mailing list
<br><a href="javascript:" target="_blank" gdf-obfuscated-mailto="GG0L6ZHLpSsJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">erlang-q...@erlang.org</a>
<br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Ferlang.org%2Fmailman%2Flistinfo%2Ferlang-questions\46sa\75D\46sntz\0751\46usg\75AFQjCNH15VBDH9qL9o1Zx3x6ZeLmwvUvTg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Ferlang.org%2Fmailman%2Flistinfo%2Ferlang-questions\46sa\75D\46sntz\0751\46usg\75AFQjCNH15VBDH9qL9o1Zx3x6ZeLmwvUvTg';return true;">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a>
<br></blockquote></div></div></div>