[Haskell-cafe] Running Total or Incremental Sum as a higher order
cryptmaster at hotmail.com
Sat Jul 3 05:29:25 EDT 2004
I was attempting to get a running a total of a list i.e
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
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.
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
More information about the Haskell-Cafe