def apply_mask(values, mask):
    """
    Convenience method to filter out values from a list according to some binary masking array.
    @param values: The list that should be filtered.
    @param mask: The masking array, must have the same length as the `values` array.
    @return: A list that contains only the selected values.
    """
    return [value for value, is_set in zip(values, mask) if is_set == 1]