UniCoreFW

pull_all_with()

Removes all elements from array that have the same value as the result of calling the comparator between the elements of array and values. The comparator is invoked with two arguments: (arr_val, oth_val).

Implementation

Args: array: The array to modify. values: The values to remove. comparator: The comparator to compare the elements of the arrays. Returns: A new list with the specified values removed.

Example

pull_all_with([1, 2, 3], [2, 3], lambda a, b: a == b)

Expected output: [1]

Source Code

def pull_all_with( array: List[T], values: List[T], comparator: Optional[Callable[[T, T], bool]] = None ) -> List[T]: if comparator is None: return [x for x in array if x not in values] return [x for x in array if not any(comparator(x, v) for v in values)]