We all can disagree what constitutes overkill. But someone has gone a step further, and generalised persistant programs' ability to remember previously requested results. Check out Memoize ("trade space for time"). It inserts itself into the call-stream somewhat magically, and detects function calls that are identical, and returns the previously-computed value for the same input.
Of course, this only makes sense when the same input always results in the same output, as it would here. This can really speed up recursive results to the point where, for some functions, the recursively-computed value is faster than the iterative. And, of course, Memoize can help simplify non-recursive functions as well. It does require a bit of caution to ensure that there are no side effects possible on a function, though.
[time elapses...] Oddly, Memoize has a bunch of add-ons that I just saw when I checked it out on CPAN (to ensure I got the link correct above) which allows this to work even for non-persistant programs. That merits some more thought. Man, do I love perl. This would be incredibly programmer-intensive in basically any other language. But in perl, someone did it already, and I can just use it. That's too cool.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|