Fixed `ans` evaluation

newfloat
Mark 2023-08-21 13:17:58 -07:00
parent edc859dc01
commit c477302c88
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
1 changed files with 10 additions and 2 deletions

View File

@ -126,6 +126,7 @@ impl Context {
} else { panic!() } } else { panic!() }
} }
// Can we define a new variable with this name?
pub fn valid_varible(&self, s: &str) -> bool { pub fn valid_varible(&self, s: &str) -> bool {
if { if {
Function::from_string(s).is_some() || Function::from_string(s).is_some() ||
@ -145,10 +146,17 @@ impl Context {
} }
} }
// Can we get a value fro mthis variable name?
pub fn is_varible(&self, s: &str) -> bool { pub fn is_varible(&self, s: &str) -> bool {
return { return {
(
s == "ans" &&
self.history.len() != 0
) ||
(
self.valid_varible(s) && self.valid_varible(s) &&
(self.variables.contains_key(s) || self.shadow.contains_key(s)) (self.variables.contains_key(s) || self.shadow.contains_key(s))
)
}; };
} }