Exemple #1
0
        def create():
            def predicate(x):
                invoked[0] += 1
                if invoked[0] == 3:
                    raise Exception(ex)

                return is_prime(x)

            return xs.pipe(ops.skip_while(predicate))
Exemple #2
0
def skip_while_indexed_(
    predicate: typing.PredicateIndexed[_T],
) -> Callable[[Observable[_T]], Observable[_T]]:
    def indexer(x: _T, i: int) -> Tuple[_T, int]:
        return (x, i)

    def skipper(x: Tuple[_T, int]) -> bool:
        return predicate(*x)

    def mapper(x: Tuple[_T, int]) -> _T:
        return x[0]

    return compose(
        ops.map_indexed(indexer),
        ops.skip_while(skipper),
        ops.map(mapper),
    )
Exemple #3
0
        def create():
            def predicate(x):
                invoked[0] += 1
                return is_prime(x)

            return xs.pipe(ops.skip_while(predicate))