This commit is contained in:
Simon Gardling 2022-03-31 09:54:39 -04:00
parent 68b4eb9454
commit 9ea2a47246
4 changed files with 14 additions and 17 deletions

View File

@ -33,7 +33,7 @@ fn generate_hashmap() {
compile_hashmap().build() compile_hashmap().build()
) )
.unwrap(); .unwrap();
write!(&mut file, ";\n").unwrap(); writeln!(&mut file, ";").unwrap();
} }
/// List of supported functions from exmex /// List of supported functions from exmex
@ -60,10 +60,10 @@ fn compile_hashmap() -> phf_codegen::Map<String> {
.filter(|e| e.len() > 1) .filter(|e| e.len() > 1)
.filter(|ele| { .filter(|ele| {
if seen.contains(ele) { if seen.contains(ele) {
return false; false
} else { } else {
seen.insert(ele.clone()); seen.insert(ele.clone());
return true; true
} }
}) })
.collect::<Vec<Vec<char>>>(); .collect::<Vec<Vec<char>>>();

View File

@ -224,7 +224,7 @@ impl FunctionEntry {
}); });
if apply_key | clicked { if apply_key | clicked {
*string = string.clone() + &selections[self.autocomplete.i]; *string = string.clone() + selections[self.autocomplete.i];
push_cursor = true; push_cursor = true;
} else { } else {
ui.memory().open_popup(popup_id); ui.memory().open_popup(popup_id);
@ -249,7 +249,7 @@ impl FunctionEntry {
TextEdit::store_state(ui.ctx(), te_id, state); TextEdit::store_state(ui.ctx(), te_id, state);
} }
} }
return func_edit_focus; func_edit_focus
} }
/// Creates and does the math for creating all the rectangles under the /// Creates and does the math for creating all the rectangles under the
@ -267,7 +267,7 @@ impl FunctionEntry {
let sum_func = self.get_sum_func(*sum); let sum_func = self.get_sum_func(*sum);
let data2: Vec<(f64, f64)> = dyn_iter(&step_helper(*integral_num, &integral_min_x, &step)) let data2: Vec<(f64, f64)> = dyn_iter(&step_helper(*integral_num, integral_min_x, &step))
.map(|x| { .map(|x| {
let step_offset = step * x.signum(); // store the offset here so it doesn't have to be calculated multiple times let step_offset = step * x.signum(); // store the offset here so it doesn't have to be calculated multiple times
let x2: f64 = x + step_offset; let x2: f64 = x + step_offset;
@ -299,16 +299,16 @@ impl FunctionEntry {
let range = self.min_x..self.max_x; let range = self.min_x..self.max_x;
let newtons_method_output: Vec<f64> = match derivative_level { let newtons_method_output: Vec<f64> = match derivative_level {
0 => newtons_method_helper( 0 => newtons_method_helper(
&threshold, threshold,
&range, &range,
&self.back_data.as_ref().unwrap(), self.back_data.as_ref().unwrap(),
&|x: f64| self.function.get(x), &|x: f64| self.function.get(x),
&|x: f64| self.function.get_derivative_1(x), &|x: f64| self.function.get_derivative_1(x),
), ),
1 => newtons_method_helper( 1 => newtons_method_helper(
&threshold, threshold,
&range, &range,
&self.derivative_data.as_ref().unwrap(), self.derivative_data.as_ref().unwrap(),
&|x: f64| self.function.get_derivative_1(x), &|x: f64| self.function.get_derivative_1(x),
&|x: f64| self.function.get_derivative_2(x), &|x: f64| self.function.get_derivative_2(x),
), ),
@ -331,7 +331,7 @@ impl FunctionEntry {
&mut self, min_x: &f64, max_x: &f64, width_changed: bool, settings: &AppSettings, &mut self, min_x: &f64, max_x: &f64, width_changed: bool, settings: &AppSettings,
) { ) {
let resolution: f64 = settings.plot_width as f64 / (max_x.abs() + min_x.abs()); let resolution: f64 = settings.plot_width as f64 / (max_x.abs() + min_x.abs());
let resolution_iter = resolution_helper(&settings.plot_width + 1, &min_x, &resolution); let resolution_iter = resolution_helper(&settings.plot_width + 1, min_x, &resolution);
// Makes sure proper arguments are passed when integral is enabled // Makes sure proper arguments are passed when integral is enabled
if self.integral && settings.integral_changed { if self.integral && settings.integral_changed {

View File

@ -260,7 +260,7 @@ pub fn newtons_method_helper(
.filter(|(prev, curr)| !prev.y.is_nan() && !curr.y.is_nan()) .filter(|(prev, curr)| !prev.y.is_nan() && !curr.y.is_nan())
.filter(|(prev, curr)| prev.y.signum() != curr.y.signum()) .filter(|(prev, curr)| prev.y.signum() != curr.y.signum())
.map(|(prev, _)| prev.x) .map(|(prev, _)| prev.x)
.map(|start_x| newtons_method(f, f_1, &start_x, &range, &threshold).unwrap_or(f64::NAN)) .map(|start_x| newtons_method(f, f_1, &start_x, range, threshold).unwrap_or(f64::NAN))
.filter(|x| !x.is_nan()) .filter(|x| !x.is_nan())
.collect() .collect()
} }

View File

@ -52,7 +52,7 @@ impl ToString for HintEnum<'static> {
.iter() .iter()
.map(|a| a.to_string()) .map(|a| a.to_string())
.collect::<String>() .collect::<String>()
.to_string(), ,
HintEnum::None => String::new(), HintEnum::None => String::new(),
} }
} }
@ -196,10 +196,7 @@ pub fn get_completion(key: String) -> Option<HintEnum<'static>> {
return None; return None;
} }
match COMPLETION_HASHMAP.get(&key) { COMPLETION_HASHMAP.get(&key).cloned()
Some(data_x) => Some(data_x.clone()),
None => None,
}
} }
/* /*