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 functools import cache | |
from sys import setrecursionlimit | |
setrecursionlimit(10000) | |
(lambda: lambda define: | |
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 collections.abc import Callable | |
from dataclasses import dataclass | |
def curry[First, *Rest, Result]( | |
function: Callable[[First, *Rest], Result], | |
) -> Callable[[*Rest], Callable[[First], Result]]: | |
return lambda *rest: lambda first: function(first, *rest) | |
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 __future__ import annotations | |
from collections.abc import Callable | |
from dataclasses import dataclass | |
from typing import cast, Final, NewType | |
class Compose[A, C]: | |
def __init__[B](self, f: Callable[[B], C], g: Callable[[A], B]) -> None: | |
self.f: Final = f |
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 __future__ import annotations | |
from collections.abc import Callable | |
from dataclasses import dataclass | |
from typing import Final, NewType | |
class Compose[Value, Result]: | |
def __init__[Intermediate](self, second: Callable[[Intermediate], Result], first: Callable[[Value], Intermediate]) -> None: | |
self.second: Final = second |
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 collections.abc import Callable | |
from dataclasses import dataclass | |
from typing import Concatenate | |
@dataclass(frozen=True) | |
class Partial1[First, **Rest, Result]: | |
function: Callable[Concatenate[First, Rest], Result] | |
first: First |
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 asyncio import run | |
from collections.abc import Coroutine | |
from dataclasses import dataclass | |
from typing import Any, Protocol | |
class Callable[*Arguments, Result](Protocol): | |
def __call__(self, *args: *Arguments) -> Result: | |
... |
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 collections.abc import Callable | |
from dataclasses import dataclass | |
from typing import Concatenate, Final | |
@dataclass(frozen=True) | |
class Partial1[First, **P, Result]: | |
function: Callable[Concatenate[First, P], Result] | |
first: First |
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 __future__ import annotations | |
from collections.abc import Callable, Iterator | |
from typing import Protocol, cast | |
type Lazy[Value] = Callable[[], Value] | |
def lazify[Value](value: Value) -> Lazy[Value]: |
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
import sys | |
from collections.abc import Callable, Iterator | |
from functools import cache | |
type Lazy[T] = Callable[[], T] | |
def run_lazy[T](lazy: Lazy[T]) -> T: |
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
import sys | |
from collections.abc import Callable, Iterator | |
from functools import cache | |
type Lazy[T] = Callable[[], T] | |
type Stream[T] = Lazy[tuple[T, Stream[T]]] |
OlderNewer