diff --git a/src/main.rs b/src/main.rs index 3a44c4e..0b86432 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 { match sexp {