Exemple #1
0
        public override LispNode Operate(LispEnvironment env, LispNode node)
        {
            LispNode err = null;

            if (LispNumberUtils.CheckIfAllNumbers(node, out err))
            {
                return(err);
            }

            var a = node.Pop() as LispNumber;

            if (node.Nested.Count == 0)
            {
                a.Number = -a.Number;
            }
            else
            {
                while (node.Nested.Count > 0)
                {
                    var b = node.Pop() as LispNumber;
                    a.Number -= b.Number;
                }
            }

            return(a);
        }
Exemple #2
0
        public override LispNode Operate(LispEnvironment env, LispNode node)
        {
            LispNode err = null;

            if (LispNumberUtils.CheckIfAllNumbers(node, out err))
            {
                return(err);
            }

            var a = node.Pop() as LispNumber;

            while (node.Nested.Count > 0)
            {
                var b = node.Pop() as LispNumber;
                if (b.Number == 0)
                {
                    return(new LispDivideByZeroException());
                }
                a.Number /= b.Number;
            }

            return(a);
        }