# Lists

import operator

def is_seq(value):
    return (isinstance(value, list) or isinstance(value, tuple)
        or isinstance(value, set))

def mk_seq(value):
    if not is_seq(value): value = [value]
    return value

def clear(list_):
    while True:
        try: list_.pop()
        except IndexError: break

def and_(list_): return reduce(operator.and_, map(bool, list_), True)

def or_(list_): return reduce(operator.or_, map(bool, list_), False)

def uniqify(list_):
    '''Removes duplicates from an iterable. Preserves order.'''
    existing = set()
    new_list = []
    for value in list_:
        if value not in existing:
            existing.add(value)
            new_list.append(value)
    return new_list
