'Take a continuous subsequence of terms of ``f``.'

def slice(f, x, m, n=None):

    if (n is None):
        (j, m, n) = (0, x, m)
    else:
        j = f._gen_to_level(x)
    (m, n) = (int(m), int(n))
    if hasattr(f.rep, 'slice'):
        result = f.rep.slice(m, n, j)
    else:
        raise OperationNotSupported(f, 'slice')
    return f.per(result)
