<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 14, 2013 at 12:23 PM, Taoufik Dachraoui <span dir="ltr"><<a href="mailto:dachraoui.taoufik@gmail.com" target="_blank">dachraoui.taoufik@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>CL-USER> (time (fac 100))<br></div><div>(FAC 100)</div><div class="im"><div>took 0 milliseconds (0.000 seconds) to run.</div>

<div>During that period, and with 1 available CPU core,</div><div>     0 milliseconds (0.000 seconds) were spent in user mode</div><div>     0 milliseconds (0.000 seconds) were spent in system mode</div></div><div> 3,864 bytes of memory allocated.</div>

<div>93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000</div></blockquote></div><br>I suspect in this case the memory allocation is happening because the number being calculated can no longer fit into an unboxed integer: indeed, compare</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">(inspect (fac 100))</div><div class="gmail_extra"><br></div><div class="gmail_extra">with</div><div class="gmail_extra"><br></div><div class="gmail_extra">(inspect (fac 6))</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">WRT the ackerman function, 32765 will fit into a machine word and can be unboxed: no allocation necessary. You get the stack overflow because, well, the recursion is blowing the stack. If you rewrote it to be iterative instead of recursive it would undoubtedly work and you would see allocation, again due to the use of a Bignum.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">    -tree<br><br clear="all"><div><br></div>-- <br>Tom Emerson<br><a href="mailto:tremerson@gmail.com" target="_blank">tremerson@gmail.com</a><br><a href="http://www.dreamersrealm.net/tree" target="_blank">http://www.dreamersrealm.net/tree</a>
</div></div>