Added an accumulate-based version of repeat.