def logical_filter(l, logicals):
    """
    Filter the list l down to the elements that correspond to the True
    elements in the list logicals.
    """
    return [val for (val, b) in zip(l, logicals) if b]