Hi

I was attempting to get a running a total of a list i.e

for [1,2,3]

the result should be

[1,3,6]   -- [1, 1+2, 2+3]

I build this function:

incrementalSum [] x = []
incrementalSum (x:xs) runningTotal = currentSum : incrementalSum xs currentSum
where
currentSum = runningTotal + x


I was trying to see how I could higher order functions for this but came up empty. Surely this is a pattern which has been abstracted ? I feel I have missed the obvious here.

Thanks,

S

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus


_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to