This file contains hidden or 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
| export TERM='screen-256color' |
This file contains hidden or 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
| @tco | |
| def fac(n, acc=1): | |
| if n == 0: | |
| return Return(acc) | |
| else: | |
| return TailCall((n - 1, n * acc)) |
This file contains hidden or 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
| def tco(fn): | |
| def inner(*args, **kwargs): | |
| result = fn(*args, **kwargs) | |
| while isinstance(result, TailCall): | |
| result = fn(*result.args, **result.kwargs) | |
| else: | |
| return result.return_val | |
| return inner |
This file contains hidden or 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
| @dataclass | |
| class TailCall: | |
| args: Tuple[Any, ...] = field(default_factory=tuple) | |
| kwargs: Dict[str, Any] = field(default_factory=dict) | |
| @dataclass | |
| class Return: | |
| return_val: Any |
This file contains hidden or 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
| @dataclass | |
| class TailCall: | |
| args: Tuple[Any, ...] = field(default_factory=tuple) | |
| kwargs: Dict[str, Any] = field(default_factory=dict) | |
| @dataclass | |
| class Return: | |
| return_val: Any |
This file contains hidden or 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
| def fac(n, acc=1): | |
| if n == 0 or n == 1: | |
| return acc | |
| else: | |
| return fac(n - 1, n * acc) |
This file contains hidden or 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
| def fac(n): | |
| acc = 1 | |
| while n > 1: | |
| acc *= n | |
| n -= 1 | |
| return acc |
This file contains hidden or 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 dataclasses import dataclass, field | |
| from typing import Any, Callable, Dict, Generic, Optional, Tuple, TypeVar, Union | |
| ReturnType = TypeVar("ReturnType") | |
| @dataclass | |
| class TailCall: | |
| args: Tuple[Any, ...] = field(default_factory=tuple) |
This file contains hidden or 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
| default partial alphanumeric_keys modifier_keys | |
| xkb_symbols "basic" { | |
| name[Group1]= "English (US)"; | |
| key <TLDE> { [ grave, asciitilde ] }; | |
| key <AE01> { [ 1, exclam ] }; | |
| key <AE02> { [ 2, at ] }; | |
| key <AE03> { [ 3, numbersign ] }; | |
| key <AE04> { [ 4, dollar ] }; |
This file contains hidden or 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
| class Thunk: | |
| def __init__(self, *args, **kwargs): | |
| self.args = args | |
| self.kwargs = kwargs | |
| def trampoline(func): | |
| def jumper(*args, **kwargs): | |
| result = func(*args, **kwargs) | |
| while isinstance(result, Thunk): | |
| result = func(*result.args, **result.kwargs) |