Skip to content

Instantly share code, notes, and snippets.

View zypeh's full-sized avatar
🔎
If you look for perfection, you'll never be content.

zypeh zypeh

🔎
If you look for perfection, you'll never be content.
View GitHub Profile
@zypeh
zypeh / evaluator.rs
Created December 14, 2020 09:12
evaluator for untyped lambda calculus
use std::boxed::Box;
#[derive(Clone, Debug)]
enum Expr {
VAR(String),
APP { func: Box<Expr>, arg: Box<Expr> },
LAM { arg: String, body: Box<Expr> },
}
type Env = Vec<(String, Val)>;
benchmarked sexp/fpbasic
time 3.193 ms (3.073 ms .. 3.357 ms)
0.989 R² (0.978 R² .. 0.998 R²)
mean 2.960 ms (2.928 ms .. 3.023 ms)
std dev 145.1 μs (89.51 μs .. 250.5 μs)
variance introduced by outliers: 28% (moderately inflated)
benchmarked sexp/fpstateful
time 3.417 ms (3.346 ms .. 3.471 ms)
0.997 R² (0.995 R² .. 0.999 R²)