public static long Parse(string expr) { expr = expr.Replace(" ", ""); expr = ParseBrackets(expr); expr = ParseAddition(expr); return(MathParser.Parse(expr)); }
public static void Run() { foreach (var n in test) { Console.WriteLine($"{n.data} evaluates to {MathParser.Parse(n.data)} ({n.resultBasic})"); } Console.WriteLine($"The sum of input questions is {data.ToList().Select(MathParser.Parse).Aggregate((a, b) => a + b)}"); foreach (var n in test) { Console.WriteLine($"{n.data} evaluates to {AdvancedMathParser.Parse(n.data)} ({n.resultAdvanced})"); } Console.WriteLine($"The sum of input questions is {data.ToList().Select(AdvancedMathParser.Parse).Aggregate((a, b) => a + b)}"); }