let head = term_stack.pop().unwrap();
let list = match tail {
+ Value::Atom(atom) if atom == "[]" => match head {
+ Value::Atom(ref a) if a.chars().collect::<Vec<_>>().len() == 1 => {
+ // Handle lists of char as strings
+ Value::String(a.to_string())
+ }
+ _ => Value::List(vec![head]),
+ },
+ Value::List(elems) if elems.is_empty() => match head {
+ Value::Atom(ref a) if a.chars().collect::<Vec<_>>().len() == 1 => {
+ // Handle lists of char as strings
+ Value::String(a.to_string())
+ },
+ _ => Value::List(vec![head]),
+ },
Value::List(mut elems) => {
elems.insert(0, head);
Value::List(elems)
Value::List(elems)
}
},
- Value::Atom(atom) if atom == "[]" => match head {
- Value::Atom(ref a) if a.chars().collect::<Vec<_>>().len() == 1 => {
- // Handle lists of char as strings
- Value::String(a.to_string())
- }
- _ => Value::List(vec![head]),
- },
_ => Value::Structure(".".into(), vec![head, tail]),
};
term_stack.push(list);