Cart -> Int more cursed

pull/2/head
ondra05 2022-01-22 20:52:09 +01:00
parent ae15f6cfb3
commit f4f7b102eb
1 changed files with 5 additions and 1 deletions

View File

@ -122,10 +122,14 @@ impl Value {
match self {
Value::Abool(a) => a as _,
Value::Bool(b) => b as _,
Value::Functio(_) => self.len(),
Value::Int(i) => i,
Value::Nul => consts::ANSWER,
Value::Str(text) => text.parse().unwrap_or(consts::ANSWER),
_ => self.len() as _,
Value::Cart(c) => c
.into_iter()
.map(|(i, v)| i.into_i32() * v.borrow().clone().into_i32())
.sum(),
}
}