Skip to content

Commit

Permalink
Fixed case sensitivity on custom operators and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BLM16 committed May 6, 2022
1 parent 31e6f32 commit 968621f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Calculator/Calculator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Copyright>Copyright © 2021 Bradley Myers. All rights reserved.</Copyright>
<RepositoryUrl>https://github.com/BLM16/Tokenized-Calculator</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>4.1.0</Version>
<Version>4.1.2</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageTags>calculator; math; solve</PackageTags>
<PackageId>BLM16.Util.$(AssemblyName)</PackageId>
Expand Down
4 changes: 2 additions & 2 deletions Calculator/Standardizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private string ComputeFunctions(string equation)
// Maps function's symbols to their operation
var funcsDict = new Dictionary<string, Func<double, string>>();
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<KeyValuePair<string, Func<double, string>>> functions = funcsDict.OrderByDescending(e => e.Key.Length).ToList();
Expand Down Expand Up @@ -176,7 +176,7 @@ private string ReplaceConstants(string equation)
// Maps the constant's symbols to its value
var constants = new Dictionary<string, double>();
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)
Expand Down

0 comments on commit 968621f

Please sign in to comment.