applyfunc¶
- class iteration_utilities.applyfunc(func, initial)¶
Successively apply func on value.
- Parameters:
- funccallable
The function to apply. The value is given as first argument to the func, no other arguments will be passed during the function call.
- initialany type
The initial value for the function.
- Returns:
- resultsgenerator
The result of the successively applied func.
Examples
The first element is the initial value and the next elements are the result of
func(value)
, thenfunc(func(value))
, …:>>> from iteration_utilities import applyfunc, getitem >>> import math >>> list(getitem(applyfunc(math.sqrt, 10), stop=4)) [3.1622776601683795, 1.7782794100389228, 1.333521432163324, 1.1547819846894583]
Warning
This will return an infinitely long generator so do not try to do something like
list(applyfunc())
!- current¶
(any type) The current value for the function (readonly).
New in version 0.6.
- func¶
(callable) The function used (readonly).
New in version 0.6.