3 ms·
I took a stab at it, there's not enough information to figure out anything more specific: from typing import Callable, Any def compose(start: Callable[[An
by albrewer 5y ago
I took a stab at it, there's not enough information to figure out anything more specific:
from typing import Callable, Any
def compose(start: Callable[[Any], Any], *args: Callable[[Any], Any] -> Callable[[Any], Any]:
def helper(x: Any) -> Any:
for func in reversed(args):
x = func(x)
return start(x)
return helper
- slaymaker1907 5y agoSure, that's probably as close as you can get, but ideally it would be possible to write a type which guarantees the input functions are compatible as well as knowing what the type is of the returned function.