repeat(times, function, *args, **kwargs)
Yield a callable step repeated a specified number of times.
Each yielded step is a function that accepts a value as its first argument
and passes it to function alongside any preconfigured positional and
keyword arguments.
Args:
times: The number of times to repeat the callable. Must be a positive integer.
function: The callable to be repeated.
args: Additional positional arguments to pass to function.
kwargs: Additional keyword arguments to pass to function.
Yields:
A callable wrapper that invokes function(value, *args, **kwargs).
Raises:
TypeError: If times is not an integer, or function is not callable.
ValueError: If times is less than or equal to 0.
Example:
def add(x, amount):
return x + amount
steps = list(repeat(3, add, 2))
# steps contains 3 wrapper functions, each adding 2
value = 0
for step in steps:
value = step(value)
# value is 6