aboutsummaryrefslogtreecommitdiffstats
path: root/src/transpile_scheme.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/transpile_scheme.rs')
-rw-r--r--src/transpile_scheme.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/transpile_scheme.rs b/src/transpile_scheme.rs
index e29a422..6f993b3 100644
--- a/src/transpile_scheme.rs
+++ b/src/transpile_scheme.rs
@@ -11,12 +11,18 @@ pub trait TranspileScheme {
impl TranspileScheme for ModelicaModel {
fn transpile_scheme(&self) -> Result<String> {
+ let mut params = vec![];
let mut constants = vec![];
for (c, e) in self.get_constant_vars() {
if let Some(v) = e {
constants.push(format!("({} {})", c, try!(v.transpile_scheme())));
+ } else {
+ params.push(c);
}
}
+ // HashMaps are unsorted, so we need to re-sort here
+ constants.sort();
+ params.sort();
let mut binds = vec![];
let mut outputs = vec![];
for eq in self.equations.iter() {
@@ -27,7 +33,9 @@ impl TranspileScheme for ModelicaModel {
bail!("Expected an identifier on LHS (in this partial implementation)")
}
}
- let args: Vec<String> = self.get_free_vars().iter().map(|s| s.clone()).collect();
+ let mut args: Vec<String> = self.get_free_vars().iter().map(|s| s.clone()).collect();
+ args.sort();
+ args.extend(params);
Ok(format!(r#"(lambda ({args})
(let ({constants})
(letrec ({binds})