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
const TERMINAL_INPUT_START = 1000; | |
const USER_CODE_START = 2000; | |
/** @type {unknown[]} */ | |
const code = []; | |
code.push( | |
_return, | |
push, | |
quit, | |
print, |
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 dataclasses import dataclass | |
from abc import ABC, abstractmethod | |
"""Perform a depth-first search for patterns in a cellular automaton. | |
Some jargon specific for this file | |
State: Possible values for a `Variable`. | |
Variable: A place where one can assign a `State` to. | |
Address: An (x, y, phase) tuple that uniquely identifies a `Variable`. | |
""" |
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
// library code for non-generic discriminated unions | |
export type ReplaceReturnType<F, R> = F extends (...args: infer Args) => any | |
? (...args: Args) => R | |
: never; | |
export type TaggedUnionFactory<TUF, R> = { | |
[K in keyof TUF]: ReplaceReturnType<TUF[K], R>; | |
}; | |
// for monomorphic types this just works well |
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
// I'm curious about your thoughts on using for loops for do-notation syntax. | |
// How does `idresultExpr`, `oresultExpr`, and `presultExpr` look? | |
// The identity monad | |
// `iterOfValue` is a generator function. | |
// it itself is a function, but it can return iterable iterators | |
function* iterOfValue<T>(x: T): Iterable<T> { | |
yield x; | |
} |