reciprocal

iteration_utilities.reciprocal(value, /)

Returns 1 / value.

Parameters
valueany type

The value for the computation.

Returns
reciprocalany type

Returns 1 / value.

Examples

This is equivalent to lambda x: 1 / x or functools.partial(operator.truediv, 1) but faster:

>>> from iteration_utilities import reciprocal 
>>> reciprocal(1)
1.0
>>> reciprocal(2)
0.5
>>> reciprocal(4)
0.25