Add a `repeat` function to the prelude

Implements a part of RFC 235.