Last active
July 19, 2022 10:38
-
-
Save V0XNIHILI/8a0050da43f03f84635c19688c2fdb22 to your computer and use it in GitHub Desktop.
Python implementation of Haskell's zipWith
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Any, Callable | |
def zip_with (func: Callable[[Any, Any], Any], list1: List[Any], list2: List[Any]) -> Any: | |
""" | |
>>> zip_with (lambda x, y: x + y, [1, 2, 3], [4, 5, 6]) | |
[5, 7, 9] | |
""" | |
return [func (x, y) for x, y in zip (list1, list2)] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment