Hello everyone.<br><br>I&#39;ve been told that syntactically recursive functions can be written as (while or for) loops. I&#39;ve already experienced converting my recursive Scheme functions to iterative Scheme functions when I wrote a _(while condition)_ and a _(for init condition update)_ function, both syntactically recursive of course. That said, whenever I have to transform a recursive function to iterative, I try to &quot;see&quot; the recursion in the pattern of my _while_ and _for_ functions. However, I find that I can&#39;t apply this method to some algorithms.<br>

<br>Consider the LCSlength(s1, s2) function (pseudocode):<br><br>LCSlength(s1, s2){<br>    :: length(s1) == 0 OR length(s2) == 0, 0<br>    :: last(s1) == last(s2), 1 + LCSlength(minus-last(s1), minus-last(s2))<br>    :: else max(LCSlength(minus-last(s1), s2), LCSlength(s1, minus-last(s2)))<br>

    }<br><br>I can write this method iteratively but only up to the second condition. I don&#39;t know how to handle the last condition in which the algorithm &quot;branches out&quot; into two and takes the branch which grew taller. Iteration, it seems to me, is very linear...<br>

<br>Or maybe I haven&#39;t been iterating enough yet? How do I go about this? Any pointers will be much appreciated. Thank you very much.<br clear="all"><br>-- <br>Chad Estioco<br>BS Computer Science (ongoing)<br>University of the Philippines-Diliman<br>

==============================<br><a href="http://www.skytreader.net">http://www.skytreader.net</a><br>