[Evaluator]
Add helper method on the evaluator to get Array objects
-use super::polynomial::Polynomial;
+use super::polynomial::{Polynomial, Array};
use std::collections::HashMap;
pub struct Environment(pub HashMap<String, Polynomial>);
@@ -14,6 +14,18 @@ impl Environment {
dbg!(name.clone());
self.0.get(&name).unwrap().clone() // XXX: Fix unwrap
}
+ pub fn get_array(&mut self, name: String) -> &Array {
+ dbg!(name.clone());
+ let poly = match self.0.get(&name) {
+ Some(poly) => poly,
+ None => panic!("Cannot find variable with name {:?}",name),
+ };
+
+ match poly {
+ Polynomial::Array(arr) => arr,
+ _=> panic!("Cannot find an array with that name")
+ }
+ }
pub fn extend(&mut self, env: &Environment) {
// XXX: Fix to use references
let map = env.0.clone();
