[fpc-pascal] More Filter Madness

Rich Saunders saunders.richard.p at gmail.com
Fri Oct 14 18:20:39 CEST 2011


On 10/14/11 2:39 AM, Nataraj S Narayan wrote:
> Good candidate for recursive algorithm i think.
At first glance maybe, but it is actually a horrible candidate. That is
due to the fact that the number of values is unknown and recursion has a
built-in limit based on the stack size. So if your logic is recursive it
will work one day on one file of numbers and not the next on a longer file.

Much better to simply maintain a summed value, read a value, add it to
the sum, write the current sum, and continue until done.




More information about the fpc-pascal mailing list