[Openmcl-devel] consing

Tom Emerson tremerson at gmail.com
Tue May 14 09:48:23 PDT 2013

On Tue, May 14, 2013 at 12:23 PM, Taoufik Dachraoui <
dachraoui.taoufik at gmail.com> wrote:

> CL-USER> (time (fac 100))
> (FAC 100)
> took 0 milliseconds (0.000 seconds) to run.
> During that period, and with 1 available CPU core,
>      0 milliseconds (0.000 seconds) were spent in user mode
>      0 milliseconds (0.000 seconds) were spent in system mode
>  3,864 bytes of memory allocated.
> 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

I suspect in this case the memory allocation is happening because the
number being calculated can no longer fit into an unboxed integer: indeed,

(inspect (fac 100))


(inspect (fac 6))

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.


Tom Emerson
tremerson at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20130514/37cb44e8/attachment.htm>

More information about the Openmcl-devel mailing list