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 {
|
fn consify(xs: &[Sexp]) -> Sexp {
|
||||||
if xs.is_empty() {
|
match xs.get(0) {
|
||||||
Sexp::nil()
|
Some(x) => {
|
||||||
} else {
|
let car = match x {
|
||||||
Sexp::List(vec![Sexp::Atom(*CONS), consify(&xs[1..])])
|
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> {
|
pub fn make_rule(sexp: &Sexp) -> Option<Rule> {
|
||||||
match sexp {
|
match sexp {
|
||||||
|
|
Loading…
Reference in a new issue