From 968621fcc87e47d1c1d4fb6902aa3ebadc873dc2 Mon Sep 17 00:00:00 2001 From: Bradley Myers Date: Fri, 6 May 2022 10:53:19 -0400 Subject: [PATCH] Fixed case sensitivity on custom operators and functions --- Calculator/Calculator.csproj | 2 +- Calculator/Standardizer.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Calculator/Calculator.csproj b/Calculator/Calculator.csproj index c777143..7b680e4 100644 --- a/Calculator/Calculator.csproj +++ b/Calculator/Calculator.csproj @@ -8,7 +8,7 @@ Copyright © 2021 Bradley Myers. All rights reserved. https://github.com/BLM16/Tokenized-Calculator git - 4.1.0 + 4.1.2 LICENSE calculator; math; solve BLM16.Util.$(AssemblyName) diff --git a/Calculator/Standardizer.cs b/Calculator/Standardizer.cs index 6bb4398..43c71e5 100644 --- a/Calculator/Standardizer.cs +++ b/Calculator/Standardizer.cs @@ -110,7 +110,7 @@ private string ComputeFunctions(string equation) // Maps function's symbols to their operation var funcsDict = new Dictionary>(); Array.ForEach(Functions, f => - Array.ForEach(f.Symbols, s => funcsDict.Add(s, f.Operation))); + Array.ForEach(f.Symbols, s => funcsDict.Add(s.ToLower(), f.Operation))); // Order the dictionary by key length List>> functions = funcsDict.OrderByDescending(e => e.Key.Length).ToList(); @@ -176,7 +176,7 @@ private string ReplaceConstants(string equation) // Maps the constant's symbols to its value var constants = new Dictionary(); Array.ForEach(Constants, c => - Array.ForEach(c.Symbols, s => constants.Add(s, c.Value))); + Array.ForEach(c.Symbols, s => constants.Add(s.ToLower(), c.Value))); // Order the dictionary by key length, replace all the keys in the equation with the values constants.OrderByDescending(e => e.Key.Length)