--- I wrote:
The solution provided by Brian is O(N^2), a solution with linear
complexity is produced using the "scanl" template of the FXSL
library:
Ooppss... I thought the question was about calculating *running total*.
Of course, calculating sub-totals is very straightforward.
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list