<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">isum :: Int -> Int<br>isum x<br> | x<10 = x<br> | otherwise = isum ((isum (x / 10)) + (x rem 10))<br>
<br>Instead of "ones" I used "rem" (imported via StdEnv -> StdInt)<br>And the recursion step is, first over x/10 and then adding that to the remainder, which is the last digit, and recursing again.<br>
</blockquote><div><br>The outer "isum" call is partially redundant, always receiving numbers from 1 to 18.<br><br><br>isum x<br><div style="margin-left: 40px;">| x < 10 = x<br></div><div style="margin-left: 40px;">
= isum0_18 ( ( isum ( x / 10 ) ) + ( x rem 10 ) )<br></div>where<br><div style="margin-left: 40px;">isum0_18 x<br><div style="margin-left: 40px;">| x < 10 = x<br>= x - 9<br></div></div><br>...is still partially redundant as "isum0_18" is never called with 0.<br>
</div></div>