def as_range(positions):
    """
    Given a list of positions, merge them into intervals if possible
    """
    l = list(positions)
    if len(l) > 1:
        return '{0}-{1}'.format(l[0], l[-1])
    else:
        return '{0}'.format(l[0])
