def partition(seq, fn):
    """Partitions one sequence into two sequences, by testing whether each element
    satisfies fn or not. """
    pos, neg = [], []
    for elt in seq:
        if fn(elt):
            pos.append(elt)
        else:
            neg.append(elt)
    return pos, neg