Example #1
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            string v1 = rpn.Pop().Token;
            string v2 = rpn.Pop().Token;

            rpn.Push(v1);
            rpn.Push(v2);
        }
Example #2
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            string v1 = rpn.Pop().Token;

            if ((dataType & Types.Infix) == Types.Infix)
            {
                rpn.Push($"{Symbols[0]}({v1})", dataType);
            }
            else
            {
                double d1 = double.Parse(v1);
                rpn.Push(SpecialFunctions.Fact(d1).ToString(), dataType);
            }
        }
Example #3
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            string v1 = rpn.Pop().Token;

            if ((dataType & Types.Infix) == Types.Infix)
            {
                rpn.Push($"1/({v1})", dataType);
            }
            else
            {
                double d1 = double.Parse(v1);
                rpn.Push((1 / d1).ToString(), dataType);
            }
        }
Example #4
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            string v1 = rpn.Pop().Token;
            string v2 = rpn.Pop().Token;

            if ((dataType & Types.Infix) == Types.Infix)
            {
                rpn.Push($"({v2}){Symbols[0]}({v1})", dataType);
            }
            else
            {
                double d1 = double.Parse(v1);
                double d2 = double.Parse(v2);
                rpn.Push(Math.Pow(d2, d1).ToString(), dataType);
            }
        }
Example #5
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            int i1 = int.Parse(rpn.Pop().Token);

            if (rpn.Count < i1)
            {
                rpn.Push(i1.ToString(), Types.Integer);
                throw new ArgumentException("Too few arguments");
            }
            StackItem[] stk = new StackItem[i1];
            Array.Copy(rpn.ToArray(), rpn.Count - i1, stk, 0, i1);
            while (--i1 >= 0)
            {
                rpn.Push(stk[i1]);
            }
        }
Example #6
0
 public override void ExecuteInternal(RPNStack rpn, Types dataType)
 {
     StackItem[] stk = new StackItem[rpn.Count];
     rpn.CopyTo(stk);
     rpn.Clear();
     for (int i = stk.Length - 2; i >= 0; i--)
     {
         rpn.Push(stk[i]);
     }
     rpn.Push(stk[^ 1]);
Example #7
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            int i1 = int.Parse(rpn.Pop().Token);

            if (i1 > rpn.Count)
            {
                throw new Exception("Too Few Arguments");
            }
            StackItem[] stk = new StackItem[rpn.Count];
            rpn.CopyTo(stk);
            rpn.Clear();
            for (int i = stk.Length - 1; i >= 0; i--)
            {
                if ((i1 - 1) != i)
                {
                    rpn.Push(stk[i]);
                }
            }
            rpn.Push(stk[i1 - 1]);
        }
Example #8
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            int i1 = int.Parse(rpn.Pop().Token);

            if (i1 > rpn.Count)
            {
                throw new Exception("Too Few Arguments");
            }
            StackItem[] stk = new StackItem[rpn.Count];
            rpn.CopyTo(stk);
            rpn.Push(stk[i1 - 1]);
        }
Example #9
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            StackItem v1 = rpn.Pop();
            StackItem v2 = rpn.Pop();

            if ((dataType & Types.Infix) == Types.Infix)
            {
                rpn.Push($"{Symbols[0]}({v2.Token},{v1.Token})", dataType);
            }
            else
            {
                double d1 = double.Parse(v1.Token);
                double d2 = double.Parse(v2.Token);
                if (d2 < d1)
                {
                    rpn.Push(v2.Token, v2.Type);
                    rpn.Push(v1.Token, v1.Type);
                    throw new ArgumentException("Bad argument value");
                }
                rpn.Push((SpecialFunctions.Fact(d2) / (SpecialFunctions.Fact(d1) * SpecialFunctions.Fact(d2 - d1))).ToString(), dataType);
            }
        }
Example #10
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            int i1 = int.Parse(rpn.Pop().Token);

            if (rpn.Count < i1)
            {
                rpn.Push(i1.ToString(), Types.Integer);
                throw new ArgumentException("Too few arguments");
            }
            while (--i1 >= 0)
            {
                rpn.Pop();
            }
        }
Example #11
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            string v1 = rpn.Pop().Token;

            if (rpn.Count == 0)
            {
                ErrorFunction = "EVAL";
                ErrorMessage  = "Too Few Arguments";
            }

            foreach (string token in rpn.InfixToRPN(v1).Split(' '))
            {
                rpn.Push(token);
            }
        }
Example #12
0
 public override void ExecuteInternal(RPNStack rpn, Types dataType)
 {
     rpn.Push("2 DUPN");
 }
Example #13
0
        public override void ExecuteInternal(RPNStack rpn, Types dataType)
        {
            double d1 = rnd.NextDouble();

            rpn.Push(d1.ToString(), Types.Float);
        }