Ejemplo n.º 1
0
def _min(comparer: Callable = None) -> Callable[[Observable], Observable]:
    """The `min` operator.

    Returns the minimum element in an observable sequence according to
    the optional comparer else a default greater than less than check.

    Examples:
        >>> res = source.min()
        >>> res = source.min(lambda x, y: x.value - y.value)

    Args:
        comparer: [Optional] Comparer used to compare elements.

    Returns:
        An observable sequence containing a single element
        with the minimum element in the source sequence.
    """

    return pipe(
        ops.min_by(identity, comparer),
        ops.map(first_only)
    )
Ejemplo n.º 2
0
 def create():
     return xs.pipe(ops.min_by(lambda x: x["key"]))
Ejemplo n.º 3
0
 def create():
     return xs.pipe(ops.min_by(lambda x: x["key"], reverse_comparer))
Ejemplo n.º 4
0
 def create():
     return xs.pipe(ops.min_by(lambda x: _raise(ex), reverse_comparer))
Ejemplo n.º 5
0
 def create():
     return xs.pipe(ops.min_by(lambda x: x["key"]))
Ejemplo n.º 6
0
 def create():
     return xs.pipe(ops.min_by(lambda x: x["key"], reverse_comparer))
Ejemplo n.º 7
0
 def create():
     return xs.pipe(ops.min_by(lambda x: _raise(ex), reverse_comparer))