Adds the string to the Octave script. At the end of the line a semicolon is appended. If the string contains a dollar sign followed by a number `i` (e.g. `$1` or `$12`) this placeholder will be replaced by the value that is stored in the vector `vals` at index `i-1`. # Example ``` # extern crate rustml; use rustml::octave::*; # pub fn main() { let s = builder().add_values("x = $1 + $2", &[5,
(&self, s: &str, vals: &[T])
| 202 | /// # } |
| 203 | /// ``` |
| 204 | pub fn add_values<T: fmt::Display>(&self, s: &str, vals: &[T]) -> OctaveScriptBuilder { |
| 205 | |
| 206 | let mut t = s.to_string(); |
| 207 | let n = vals.len(); |
| 208 | |
| 209 | for i in (0..n) { |
| 210 | let p = format!("${}", i + 1); |
| 211 | let v = format!("{}", vals[i]); |
| 212 | t = t.replace(&p, &v); |
| 213 | } |
| 214 | self.add(&t) |
| 215 | } |
| 216 | |
| 217 | pub fn octave_bin(&self, path: &str) -> OctaveScriptBuilder { |
| 218 | OctaveScriptBuilder { |