implement accumulate with callback
implement accmulate with functor