functools¶
Higher-order functions and operations on callable objects, similar to Python's functools module.
Functions¶
functools.reduce(func: Func[T, T, T], iterable: Iterable[T]) -> T¶
Apply a function of two arguments cumulatively to the items of iterable, from left to right, so as to reduce the iterable to a single value.
Parameters:
func(Func[T, T, T]) -- A function of two arguments.iterable(Iterable[T]) -- The iterable to reduce.
Returns: The single result of the cumulative application.
Raises:
TypeError-- Thrown if the iterable is empty.
functools.reduce(func: Func[T, T, T], iterable: Iterable[T], initial: T) -> T¶
Apply a function of two arguments cumulatively to the items of iterable, from left to right, starting with initial, so as to reduce the iterable to a single value.
Parameters:
func(Func[T, T, T]) -- A function of two arguments.iterable(Iterable[T]) -- The iterable to reduce.initial(T) -- The initial (seed) value.
Returns: The single result of the cumulative application.
functools.cmp_to_key(func: Func[T, T, int]) -> IComparer[T]¶
Convert a comparison function into a key function suitable for use
with sorting. Returns an IComparer{T} that wraps the
comparison function.
Parameters:
func(Func[T, T, int]) -- A comparison function that returns a negative number for less-than, zero for equal, or a positive number for greater-than.
Returns: An IComparer{T} wrapping the comparison function.