Skip to content

Instantly share code, notes, and snippets.

@divs1210
divs1210 / cek.py
Last active June 21, 2020 17:24 — forked from cheery/cek.py
CEK abstract machine
class Var(object):
def __init__(self, name):
self.name = name
def __repr__(self):
return self.name
class Lam(object):
def __init__(self, bind, expr):
self.bind = bind
@divs1210
divs1210 / with-retry.clj
Last active October 17, 2022 16:05 — forked from aphyr/with-retry.clj
Recur from within catch block
(defrecord Retry [bindings])
(defmacro with-retry
"It's really inconvenient not being able to recur from within (catch)
expressions. This macro wraps its body in a (loop [bindings] (try ...)).
Provides a (retry & new bindings) form which is usable within (catch) blocks:
when this form is returned by the body, the body will be retried with the new
bindings."
[initial-bindings & body]
(assert (vector? initial-bindings))