Skip to content

Instantly share code, notes, and snippets.

View arjunguha's full-sized avatar
:shipit:
Why does this exist?

Arjun Guha arjunguha

:shipit:
Why does this exist?
View GitHub Profile
@arjunguha
arjunguha / Arith.ml
Last active December 22, 2015 14:48
Code from Friday, September 6th
open Arith_syntax
let rec subst (x : id) (v : int) (e : exp) : exp =
match e with
| Int _ -> e
| Add (e1, e2) -> Add (subst x v e1, subst x v e2)
| Mul (e1, e2) -> Mul (subst x v e1, subst x v e2)
| Let (y, e1, e2) ->
Let (y, subst x v e1, if x = y then e2 else subst x v e2)
| Id y -> if x = y then Int v else Id y