drop_while()
Creates a slice of `array` excluding elements dropped from the beginning. Elements are dropped until `predicate` returns falsey. The predicate is invoked with three arguments: (value, index, array).
Implementation
Args: array: List to process. predicate: Function invoked per iteration. Returns: Dropped list.
Example
drop_while([1, 2, 3, 4], lambda x: x < 3)
Expected output: [3, 4]
Source Code
def drop_while(array: List[T], predicate: Callable[[T], bool]) -> List[T]:
for idx, x in enumerate(array):
if not predicate(x):
return array[idx:]
return []