Last active
December 26, 2022 20:11
-
-
Save Harduim/ed5cfdec42e9eb551fc3619fbce8d359 to your computer and use it in GitHub Desktop.
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 Iterable, TypeVar | |
T = TypeVar("T") | |
def first(items: Iterable[T], pred: callable) -> T | None: | |
return next((i for i in items if pred(i)), None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment