<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 8, 2013 at 9:34 PM, Jens Axel Søgaard <span dir="ltr">&lt;<a href="mailto:jensaxel@soegaard.net" target="_blank">jensaxel@soegaard.net</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="im"><span style="font-family:arial,sans-serif;font-size:16.363636016845703px">&gt; Would it make sense to use memoization more broadly for the definition of the factorial </span><div>

<span style="font-family:arial,sans-serif;font-size:16.363636016845703px">&gt; in the math lib, maybe with a `provide&#39;d parameter to control how many values can be </span></div>
<div><span style="font-family:arial,sans-serif;font-size:16.363636016845703px">&gt; memoized?</span><br></div><div><span style="font-family:arial,sans-serif;font-size:16.363636016845703px"><br></span></div></div><div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">An interesting question. First of all it seems that especially binomial</span></font></div>


<div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">can be improved. Second I think there is a difference between </span></font></div><div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">non-permanent caching and permanent caching. I see no problem</span></font></div>


<div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">with non-permanent caching. For caching between calls I am not</span></font></div><div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">sure, what is the best solution for a general purpose library.</span></font></div>


<div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">I lean towards non-caching functions as standard, but it would</span></font></div><div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">be nice to offer both versions in the library. The same problem</span></font></div>


<div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">arises in prime? . Having a large table of small primes </span></font></div><div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">improve the running time, but is a reasonable table</span></font></div>


<div><font face="arial, sans-serif"><span style="font-size:16.363636016845703px">size 10^3, 10^4 or 10^5 ? </span></font></div></div></blockquote><div><br></div><div>Hence the idea of the parameter (or several?), with a default correct general value that can be changed by the user.<br>

<br></div><div>Btw, the factorial table uses some unnecessary memory space (though not that big anyway), I think it would be better to request memory on demand. <br></div><div>Memoization with a hash table does exactly that, although a growable vector would fit too.<br>

</div><div>I guess the same goes for `prime?&#39; and maybe other places?<br></div><div><br></div></div>Laurent<br></div></div>