예제 #1
0
        public void CustomFunction()
        {
            var compiler = new EquationCompiler("factorial(5)");

            compiler.AddFunction("factorial", x =>
            {
                int factorial = 1;
                for (int i = 1; i <= x; i++)
                {
                    factorial *= i;
                }

                return(factorial);
            });

            Assert.AreEqual(5 * 4 * 3 * 2 * 1, compiler.Calculate());
        }