Second iteration for accumulate, making a use of the lazyness of Haskell