Is there something existing in python that can convert an increasing list of integers into a range list
E.g. given the set {0, 1, 2, 3, 4, 7, 8, 9, 11} I want to get
Put it shorter:
ranges=lambda l:map(lambda x:(x[0][1],x[-1][1]),map(lambda (x,y):list(y),itertools.groupby(enumerate(l),lambda (x,y):x-y)))