improvements

General code improvements and optimizations.
This commit is contained in:
Simon Gardling
2022-05-12 20:03:53 -04:00
parent 1c8198103e
commit f916de7524
12 changed files with 94 additions and 60 deletions

View File

@@ -13,7 +13,7 @@ pub use crate::{
autocomplete_hashmap::compile_hashmap,
parsing::{process_func_str, BackingFunction},
suggestions::{
generate_hint, get_last_term, split_function, split_function_chars, Hint, HINT_EMPTY,
SUPPORTED_FUNCTIONS,
generate_hint, get_last_term, split_function, split_function_chars, Hint, SplitType,
HINT_EMPTY, SUPPORTED_FUNCTIONS,
},
};

View File

@@ -191,5 +191,6 @@ pub fn process_func_str(function_in: &str) -> String {
return String::new();
}
crate::suggestions::split_function(&function_in).join("*")
crate::suggestions::split_function(&function_in, crate::suggestions::SplitType::Multiplication)
.join("*")
}

View File

@@ -14,7 +14,7 @@ macro_rules! test_print {
};
}
pub fn split_function(input: &str) -> Vec<String> {
pub fn split_function(input: &str, split: SplitType) -> Vec<String> {
split_function_chars(
&input
.replace("pi", "π") // replace "pi" text with pi symbol
@@ -22,7 +22,7 @@ pub fn split_function(input: &str) -> Vec<String> {
.replace("exp", "\u{1fc93}") // stop-gap solution to fix the `exp` function
.chars()
.collect::<Vec<char>>(),
SplitType::Multiplication,
split,
)
.iter()
.map(|x| x.replace("\u{1fc93}", "exp")) // Convert back to `exp` text