Treat a sequence as a circular sequence

Create a circular (repeating) sequence from an input sequence, optionally limiting the total number of elements.