(cls, spans)
return spans
Merges overlapping and touches spans in the given list of spans.

        Note that this modifies the original list.

        >>> spans = [Span(1,2), Span(3)]
        >>> Span.merge(spans)
        >>> spans
        [<1-3>]
Merges overlapping and touches spans in the given list of spans.
Merges overlapping and touches spans in the given list of spans .
def merge(cls, spans):
        """Merges overlapping and touches spans in the given list of spans.

        Note that this modifies the original list.

        >>> spans = [Span(1,2), Span(3)]
        >>> Span.merge(spans)
        >>> spans
        [<1-3>]
        """

        i = 0
        while i < len(spans) - 1:
            here = spans[i]
            j = i + 1
            while j < len(spans):
                there = spans[j]
                if there.start > here.end + 1:
                    break
                if here.touches(there) or here.overlaps(there):
                    here = here.to(there)
                    spans[i] = here
                    del spans[j]
                else:
                    j += 1
            i += 1
        return spans
def merge ( cls , spans ) : i = 0 while i < len ( spans ) - 1 : here = spans [ i ] j = i + 1 while j < len ( spans ) : there = spans [ j ] if there . start > here . end + 1 : break if here . touches ( there ) or here . overlaps ( there ) : here = here . to ( there ) spans [ i ] = here del spans [ j ] else : j += 1 i += 1 return spans