reciprocal

iteration_utilities.reciprocal(value, /)

Returns 1 / value.

Parameters:

value : any type

The value for the computation.

Returns:

reciprocal : any type

Returns 1 / value.

Examples

This is equivalent to lambda x: 1 / x (or lambda x: 1. / x Python2) 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