aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modelica_ast.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/modelica_ast.rs b/src/modelica_ast.rs
index 33af4ac..6903900 100644
--- a/src/modelica_ast.rs
+++ b/src/modelica_ast.rs
@@ -104,7 +104,7 @@ impl ModelicaModel {
vars.map(|c| c.name.clone()).collect()
}
-fn union_vecs(a: &Vec<String>, b: &Vec<String>) -> Vec<String> {
+fn union_strings(a: &Vec<String>, b: &Vec<String>) -> Vec<String> {
let mut u = a.clone();
for e in b {
if !(u.contains(&e)) {
@@ -114,6 +114,16 @@ fn union_vecs(a: &Vec<String>, b: &Vec<String>) -> Vec<String> {
u
}
+fn intersect_strings(a: &Vec<String>, b: &Vec<String>) -> Vec<String> {
+ let mut both = vec![];
+ for e in a {
+ if b.contains(&e) {
+ both.push(e.clone());
+ }
+ }
+ both
+}
+
impl Expr {
// Order is undefined
@@ -124,7 +134,7 @@ impl Expr {
Ident(ref s) => vec![s.clone()],
Der(ref e) | Abs(ref e) => e.identifiers(),
BinExpr(_, ref e1, ref e2) => {
- union_vecs(&e1.identifiers(), &e2.identifiers())
+ union_strings(&e1.identifiers(), &e2.identifiers())
},
}
}
@@ -138,7 +148,7 @@ impl SimpleEquation {
// Order is undefined
pub fn identifiers(&self) -> Vec<String> {
- union_vecs(&self.lhs.identifiers(), &self.rhs.identifiers())
+ union_strings(&self.lhs.identifiers(), &self.rhs.identifiers())
}
pub fn contains(&self, ident: &str) -> bool{