[fpc-pascal] More Filter Madness

Alberto Narduzzi albertonarduzzi at yahoo.com
Sat Oct 15 22:03:05 CEST 2011

>  >> Good candidate for recursive algorithm i think.
>  > At first glance maybe, but it is actually a horrible candidate.

IMHO, this is far from being a problem that needs to be solved with 
recursion. Indeed, you don't need recursion at all: you have a file, and 
just need to sum its values till EOF; only you need also to show the 
partial result at each step.
Moreover, since the file has a well known beginning and end, a cycle is 
more than enough.
Recursion is for other things, such as expression parsing etc. where you 
don't (and neither possibly can't) actually know how deep may the nesting.

Just my 2c

Cheers, A.

Alberto Narduzzi
ANSware Ltd.

More information about the fpc-pascal mailing list