""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |
;; my_addr(MYADDR) get_jwa_method_id(103289) args(2) master_code ret(1) master_data | |
;; RUNVM +1 +4 +32 | |
;; address exitcode c4' c5' | |
slice vm::invoke_get_addr(cell master_code, cell master_data) asm | |
"MYADDR // mc md my_addr" | |
"103829 PUSHINT // mc md my_addr get_jwa_method_id" | |
"2 PUSHINT // mc md my_addr get_jwa_method_id args" | |
"2 3 BLKSWAP // my_addr get_jwa_method_id args mc md" | |
"1 PUSHINT // my_addr get_jwa_method_id args mc md ret" |
const std = @import("std"); | |
const Build = std.Build; | |
pub fn build(b: *Build) void { | |
const target = b.standardTargetOptions(.{}); | |
const optimize = b.standardOptimizeOption(.{}); | |
// Instead of using the classic b.addExecutable, we use a custom rule | |
// to compile with Zig, then optimize with LLVM. | |
const exe = addLLvmExecutable(b, .{ |
trait Interp { | |
type Repr<T>; | |
fn lit(i: i32) -> Self::Repr<i32>; | |
fn add(a: Self::Repr<i32>, b: Self::Repr<i32>) -> Self::Repr<i32>; | |
} | |
struct Eval; | |
impl Interp for Eval { |
I've recently been amazed, if not mind-blown, by how a very simple, "one-line" SAT solver on Interaction Nets can outperform brute-force by orders of magnitude by exploiting "superposed booleans" and optimal evaluation of λ-expressions. In this brief note, I'll provide some background for you to understand how this works, and then I'll present a simple code you can run in your own computer to observe and replicate this effect. Note this is a new observation, so I know little about how this algorithm behaves asymptotically, but I find it quite
Welcome to imaginary book club! I hope everyone finished the reading this week. No? Fine, we'll just wing it. At least there's snacks.
There is a deck of cards. Each has a question on it. Play starts with a random player and proceeds in a circle, with each player drawing a card and answering the question. The first two are always:
- What is the book's title?
- What is the book's genre?
let discard _a b = b | |
let rec pp lvl = function | |
| `Lam f -> "(λ" ^ pp (lvl + 1) (f (`Go lvl)) ^ ")" | |
| `Pi (a, f) -> "(Π" ^ pp lvl a ^ "." ^ pp (lvl + 1) (f (`Go lvl)) ^ ")" | |
| `Appl (m, n) -> "(" ^ pp lvl m ^ " " ^ pp lvl n ^ ")" | |
| `Ann (m, a) -> "(" ^ pp lvl m ^ " : " ^ pp lvl a ^ ")" | |
| `Go x -> string_of_int x | |
| `Star -> "*" | |
| `Box -> "☐" |