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
| <html> | |
| <head> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"> | |
| <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script> | |
| </head> | |
| <body> | |
| <script> | |
| function html(text, ...values) { | |
| const html = text.flatMap((text, i) => { | |
| return [text, values[i]?.outerHTML || values[i]] |
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 typing import ParamSpec, TypeVar, Callable, reveal_type | |
| T = TypeVar("T") | |
| P = ParamSpec("P") | |
| def tco(f: Callable[P, T]) -> Callable[P, T]: | |
| unwind = False |
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 typing import * | |
| from typing_extensions import ParamSpec | |
| A = TypeVar("A") | |
| B = TypeVar("B") | |
| C = TypeVar("C") | |
| D = TypeVar("D") | |
| E = TypeVar("E") | |
| F = TypeVar("F") | |
| G = TypeVar("G") |
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 Calcparser | |
| prechigh | |
| left '*' '/' | |
| left '+' '-' | |
| preclow | |
| options no_result_var | |
| rule | |
| target: expr |
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
| open Format | |
| type term = | |
| | Var of int | |
| | Lamb of term | |
| | App of term * term | |
| let rec shift i depth = function | |
| | Var x when x < depth -> Var x | |
| | Var x -> Var (x + i) |
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
| open Printf | |
| let (%) = Int.logor | |
| let (<<) = Int.shift_left | |
| let (>>) = Int.shift_right | |
| let (&) = Int.logand | |
| let utf_8_bytes_of_unicode i = | |
| if i <= 0x007F | |
| then |
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
| (** | |
| * Closed Terms Lambda Caulcus with De Bruijn Indexes | |
| * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| *) | |
| open Format | |
| type term = | |
| | Var of int | |
| | Lamb of int * term |
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
| import sys | |
| from functools import partial | |
| class Pipe: | |
| def __init__(self, f, *args, **kwargs): | |
| self.f = f | |
| self.args = args | |
| self.kwargs = kwargs | |
| def __call__(self, replacement): | |
| args = [arg if arg is not Ellipsis else replacement |
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 typing import * | |
| import ast | |
| from dataclasses import dataclass | |
| @dataclass(frozen=True) | |
| class FuncSig: | |
| name : str | |
| args : list[str] | |
| ret: str |
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
| open Printf | |
| type term = F of string * (term list) | V of string | |
| let rec subst term ((name, replacement) as sub) = | |
| match term, name with | |
| | V x, V y when String.equal x y -> replacement | |
| | V x, V y when not (String.equal x y) -> term | |
| | F (x, args), V y -> F (x, List.map (fun arg -> subst arg sub) args) | |
| | _, _ -> assert false |