Skip to content

Instantly share code, notes, and snippets.

View Z-Shang's full-sized avatar
💭
She / Her

Z-Shang Z-Shang

💭
She / Her
View GitHub Profile
@Z-Shang
Z-Shang / tco.py
Created September 6, 2018 11:44
Working yet naive Tail Call Optimisation (Trampoline) in Python
from collections import namedtuple
TailCall = namedtuple("TailCall", ['fn', 'args', 'kargs'])
class tco:
def __init__(self, f):
self.fn = f
def __call__(self, *a, **k):
retval = self.fn(*a, **k)
@Z-Shang
Z-Shang / fsm.lisp
Created February 11, 2018 15:42
Naive-FSM
(in-package :cl-user)
(defpackage :naive-fsm
(:use :cl)
(:export
#:new-mm
#:state
#:on
#:mwhen
#:trigger