Skip to content

Commit

Permalink
add fst & snd
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyNikiforov committed Oct 10, 2024
1 parent 83ec020 commit b8a8646
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/foundation/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, TypeVar
from typing import Callable, Tuple, TypeVar

_Tin = TypeVar("_Tin")
_Tin2 = TypeVar("_Tin2")
Expand Down Expand Up @@ -128,3 +128,19 @@ def _intern3(input3: _Tin3) -> _Tout:
return _intern2

return _intern


def fst(t: Tuple[_Tin, _Tin2]) -> _Tin:
"""get first of tuple
>>> fst((1, 2)) == 1
True
"""
return t[0]


def snd(t: Tuple[_Tin, _Tin2]) -> _Tin2:
"""get second of tuple
>>> snd((1, 2)) == 2
True
"""
return t[1]

0 comments on commit b8a8646

Please sign in to comment.