UniCoreFW

times()

Call the given function `n` times, passing the iteration index to `func`.

Implementation

Args: n: Number of times to call the function func: A function that takes the index as an argument Returns: A list of the results

Example

times(3, lambda x: x * x)

Expected output: [0, 1, 4]

Source Code

def times(n: int, func: Callable[[int], T]) -> List[T]: return [func(i) for i in range(n)]