fix quote
made it so that consify works properly on list of lists
This commit is contained in:
parent
aa40bfedbb
commit
9c65b1618b
1 changed files with 11 additions and 4 deletions
15
src/main.rs
15
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<Rule> {
|
||||
match sexp {
|
||||
|
|
Loading…
Reference in a new issue