(indices)
Group the given integer indices into slices
Group the given integer indices into slices
Group the given integer indices into slices
def slices(indices):
    """ Group the given integer indices into slices
    """
    indices = list(sorted(indices))
    if indices:
        first = last = indices[0]
        for i in indices[1:]:
            if i == last + 1:
                last = i
            else:
                yield first, last + 1
                first = last = i
        yield first, last + 1
def slices ( indices ) : indices = list ( sorted ( indices ) ) if indices : first = last = indices [ 0 ] for i in indices [ 1 : ] : if i == last + 1 : last = i else : yield first , last + 1 first = last = i yield first , last + 1