fix quote

made it so that consify works properly on list of lists
This commit is contained in:
mehbark 2023-06-14 23:34:04 -04:00
parent aa40bfedbb
commit 9c65b1618b

View file

@ -897,12 +897,19 @@ impl<'src> SpecialForm<'src> for Quote<'src> {
}
fn consify(xs: &[Sexp]) -> Sexp {
if xs.is_empty() {
Sexp::nil()
} else {
Sexp::List(vec![Sexp::Atom(*CONS), consify(&xs[1..])])
match xs.get(0) {
Some(x) => {
let car = match x {
Sexp::Atom(_) => x.clone(),
Sexp::List(xs) => consify(xs),
};
Sexp::List(vec![Sexp::Atom(*CONS), car, consify(&xs[1..])])
}
None => Sexp::nil(),
}
}
// Sexp::List(vec![Sexp::Atom(*CONS), consify(&xs[1..])])
pub fn make_rule(sexp: &Sexp) -> Option<Rule> {
match sexp {