Skip to content

Instantly share code, notes, and snippets.

@mseddon
mseddon / simple-observer.ts
Last active March 10, 2019 16:56
Simple observer class decorator for preact and nx-js/observer-util.
import { observe, unobserve } from "@nx-js/observer-util";
export const observer = (klass) => {
let kp = klass.prototype,
cwm = kp.componentWillMount,
cdu = kp.componentDidUnmount;
kp.componentWillMount = function() {
this.render = observe(this.render, { scheduler: () => this.setState(), lazy: true })
cwm && cwm.apply(this, arguments);
}
@mseddon
mseddon / interpreter.ts
Last active February 11, 2020 18:45
Scarab-∞ CESK core
/**
* Scarab Lisp interpreter. Runs Scarab-∞ in ANF with full first class continuations.
*
* This is a CEK machine, with *mutable* environments. (so remember to migrate to CESK for formal work, derp).
*
*/
import { Let0, Lit, VarRef, App, If, SetQ, Fn, CallCC, RuntimeEnv, Var, Env, AExp, Exp, PApp } from "./ir";
import { NIL } from "../scarab-core/lists";
export const STEP: unique symbol = Symbol("step");
export const AEXP: unique symbol = Symbol("aexp");