def reverse_slice(input, start, length):
    """Reverses a slice of the input list, wrapping around if necessary."""
    output = list(input)
    for i, pos in enumerate(range(start, start + length)):
        output[pos % len(output)] = input[(start + length - i - 1) % len(output)]
    return output