From 313c044b4a878a425aaca6554576f5154ace8ff9 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Wed, 6 Aug 2025 16:23:18 +0300 Subject: Implemented let-bindings --- src/sexp/subst.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/sexp/subst.rs') diff --git a/src/sexp/subst.rs b/src/sexp/subst.rs index 87f9b50..4cfa48d 100644 --- a/src/sexp/subst.rs +++ b/src/sexp/subst.rs @@ -17,7 +17,14 @@ impl SExp { /// ``` pub fn subst(self, name: &str, value: &SExp) -> SExp { match self { - SCons(a, b) => scons((*a).subst(name, value), (*b).subst(name, value)), + SCons(a, b) => { + if let Some((varname, _)) = a.clone().check_let() { + if &varname == name { + return SCons(a, b); + } + } + scons((*a).subst(name, value), (*b).subst(name, value)) + }, Atom(Var(x)) if x == name => value.clone(), t => t, } -- cgit v1.2.3