From 6723354e83cab6e42b6ebfbeb752b576072440ee Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 17 Feb 2022 11:35:16 -0500 Subject: [PATCH] no factorials --- src/lib.rs | 5 +++++ www/index.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 3e7002a..628b202 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,6 +65,11 @@ impl ChartManager { // Tests function to make sure it's able to be parsed. Returns the string of the Error produced, or an empty string if it runs successfully. pub fn test_func(function_string: String) -> String { + // Factorials do not work, and it would be really difficult to make them work + if function_string.contains("!") { + return "Factorials are unsupported".to_string(); + } + let new_func_str: String = add_asterisks(function_string.clone()); let expr_result = new_func_str.parse(); let expr_error = match &expr_result { diff --git a/www/index.js b/www/index.js index 66e527f..1973f30 100644 --- a/www/index.js +++ b/www/index.js @@ -122,8 +122,10 @@ function checkVariables() { function errorRecommend(error_string) { if (error_string.includes("Evaluation error: unknown variable ")) { return "This variable is not considered valid. Make sure you used a valid variable."; + } else if (error_string == "Factorials are unsupported") { + return ""; } else { - return "Make sure you're using proper syntax! Check console log (f12) as well for more details."; + return "Make sure you're using proper syntax! Check console log (press F12) as well for more details."; } }