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
| #lang racket/base | |
| (define (build-jumps code) | |
| (define code-len (string-length code)) | |
| (define jumps (make-hash)) | |
| (define stack '()) | |
| ;; precompute jumps | |
| (for ([i (in-range code-len)]) | |
| (define c (string-ref code 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
| import Foundation | |
| struct Point { | |
| let x: Int | |
| let y: Int | |
| } | |
| struct Border { | |
| let bx: Int | |
| let up: Bool |
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 __future__ import annotations | |
| from dataclasses import dataclass | |
| from pathlib import Path | |
| import sys | |
| @dataclass | |
| class Point: | |
| x: int | |
| y: int |
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
| --https://adventofcode.com/2025/day/9 | |
| -- Timing on my machine (Intel i7-10710U): | |
| -- When run directly via "e1 prog.e1" ("interpreted" mode): 42.9 seconds | |
| -- When compiled via Racket ("e1 --rkt prog.e1; raco exe prog.rkt"): 14.5 seconds | |
| -- When translated into Python | |
| -- https://gist.github.com/thedeemon/d8df30420f3e57bcb853250b6c06ab5c | |
| -- Python 3.12.10: 513.5 seconds | |
| -- Python 3.14.2: 262.9 seconds | |
| -- Translated to Swift: 2.1 seconds |
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
| // Formats only the changed lines mentioned in "git diff". | |
| // Removes trailing whitespace and in leading whitespace converts tabs to spaces. | |
| // Made with Codex. | |
| import Foundation | |
| struct ParsedDiff { | |
| let files: [FileChange] | |
| } |
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
| type Maybe a = Some { value : a } | None | |
| class Conv a b { | |
| $ : a -> b | |
| } | |
| instance Conv a String where Show a { | |
| $ = show | |
| } |
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 Foundation | |
| struct Complex { | |
| var re: Double | |
| var im: Double | |
| static func +(lhs: Complex, rhs: Complex) -> Complex { | |
| Complex(re: lhs.re + rhs.re, im: lhs.im + rhs.im) | |
| } |
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 Iterator it -> a { | |
| next : it -> Maybe a | |
| } | |
| type IotaIter { | |
| mut cur : Int | |
| end : Int | |
| } | |
| instance Iterator IotaIter Int { |
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
| -- What works now as of March 12, 2026. | |
| -- Comments start with -- and go until the end of line. | |
| -- Any combination of +-*/<>=:%^&|!~$?# is an operator. | |
| -- But these are part of language syntax: | => -> = : | |
| -- Identifiers start with a lowercase letter and then may have | |
| -- letter, digits, _ and ?. | |
| -- Type names and data constructors start with an uppercase letter |
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
| // Integrate timelike geodesics in the equatorial plane (θ = π/2) of a Schwarzschild spacetime | |
| // ----------------------------------------------------------------------------- | |
| // Units: c = G = 1. Mass M is given in the same geometric units (Schwarzschild radius r_s = 2M). | |
| // Coordinates: (t, r, φ) with affine parameter λ. | |
| // State vector y = (t, r, φ, 𝑡̇, ṙ, φ̇) where dots denote d/dλ. | |
| // ----------------------------------------------------------------------------- | |
| import Foundation | |
| /// Complete phase–space state of a particle on the geodesic | |
| struct State { |
NewerOlder