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 June 1, 2025. | |
-- 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 ?. |
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 { |
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 | |
// This program is mostly generated by ChatGPT o1 in a long conversation | |
// based on this PDF: https://arxiv.org/pdf/2206.12042 | |
// "Experimental Demonstration of Quantum Pseudotelepathy" | |
struct Complex: CustomStringConvertible { | |
var re: Double | |
var im: Double | |
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 | |
// MARK: — Complex number struct | |
struct Complex { | |
var re: Double | |
var im: Double | |
func conjugate() -> Complex { | |
Complex(re: re, im: -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
#lang racket/base | |
(require racket/file racket/string) | |
(for ([fname (current-command-line-arguments)]) | |
(displayln fname) | |
(define ls (file->lines fname)) | |
(display-lines-to-file | |
(map (λ (s) (string-trim (string-replace s "\t" " ") " " #:left? #f #:repeat? #t)) ls) | |
fname #:exists 'replace)) |
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 std.stdio, core.bitop, std.array, std.format, std.exception : enforce; | |
struct Entry(K,V) { | |
K key; | |
V value; | |
uint id; | |
} | |
enum maxShift = 25; |
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
enum Ible[e] { | |
case MkIter(Int32, Int32 -> e) | |
} | |
instance Iterable[Ible] { | |
pub def iterator(rc: Region[r], s: Ible[a]): Iterator[a, r, r] \ r = | |
let Ible.MkIter(n, f) = s; | |
Iterator.range(rc, 0, n) |> Iterator.map(f) | |
} |
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 br | |
(require br-parser-tools/lex brag/support br/macro "grammar.rkt") | |
(define-lex-abbrev digits (:+ numeric)) | |
(define-lex-abbrev reserved-terms | |
(:or "+" "-" "*" "/" "=" "in" ";" "{" "}" "(" ")" "," "=>" "if" "then" "else" "==" "<")) | |
(define (tokenize ip) | |
(port-count-lines! ip) | |
(define my-lexer |
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 brag | |
s-prog: s-stmt (/";" s-stmt)* | |
@s-stmt: s-assn | s-fundef | s-expr | |
s-funcall: NAME /"(" [s-expr (/"," s-expr)*] /")" | |
s-fundef: NAME /"(" [NAME (/"," NAME)* ] /")" "=>" s-expr | |
s-block: /"{" [s-stmt (/";" s-stmt)* /"in"] s-expr /"}" | |
s-assn: NAME /"=" s-expr | |
s-expr: s-compterm | if | |
if: /"if" s-expr /"then" s-expr /"else" s-expr | |
s-compterm: s-term [("<" | "==") s-term] |
NewerOlder