iterateM package:contiguous

Apply a function n times to a value and construct a mutable array where each consecutive element is the result of an additional application of this function. The zeroth element is the original value.
Apply a monadic function n times to a value and construct a mutable array where each consecutive element is the result of an additional application of this function. The zeroth element is the original value.