from functools import reduce


def partition(tosplit, predicate):
    """
    Splits the list :param:`tosplit` based on the :param:`predicate` applied to each
    list element and returns the two resulting lists

    Parameters
    ----------
    tosplit: list
        The list to split
    predicate: :class:`six.Callable`
        A callable predicate that takes as an argument a list element to test.

    Returns
    -------
    true_list: list
        The list of elements in :param:`tosplit` for which :param:`predicate` were
        True
    false_list: list
        The list of elements in :param:`tosplit` for which :param:`predicate` were
        False
    """
    return reduce(lambda x, y: x[not predicate(y)].append(y) or x, tosplit,
                  ([], []))