Fix lists of chars as strings
This commit is contained in:
@@ -194,6 +194,20 @@ impl Value {
|
|||||||
let head = term_stack.pop().unwrap();
|
let head = term_stack.pop().unwrap();
|
||||||
|
|
||||||
let list = match tail {
|
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) => {
|
Value::List(mut elems) => {
|
||||||
elems.insert(0, head);
|
elems.insert(0, head);
|
||||||
Value::List(elems)
|
Value::List(elems)
|
||||||
@@ -213,13 +227,6 @@ impl Value {
|
|||||||
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]),
|
_ => Value::Structure(".".into(), vec![head, tail]),
|
||||||
};
|
};
|
||||||
term_stack.push(list);
|
term_stack.push(list);
|
||||||
|
|||||||
Reference in New Issue
Block a user