Example #1
0
        public override RecursionResult <KObject> Combine(KObject args, KEnvironment env, Continuation <KObject> cont)
        {
            var res = CheckParameter(args, 2, "*");

            if (res != null)
            {
                return(CPS.Error(res, cont));
            }
            KObject a = First(args), b = Second(args);
            var     result = KNumber.DoMath(a, b, (x, y) => x * y, (x, y) => x * y);

            if (result == null)
            {
                return(CPS.Error("*: wrong types", cont));
            }
            return(Return(result, cont));
        }
Example #2
0
        public override RecursionResult <KObject> Combine(KObject args, KEnvironment env, Continuation <KObject> cont)
        {
            var res = CheckParameter(args, 2, "-");

            if (res != null)
            {
                return(CPS.Error(res, cont));
            }
            KObject a = First(args), b = Second(args);

            if (KNumber.IsNumber(b) && KNumber.GetDouble(b) == 0.0)
            {
                return(CPS.Error("Division by zero", cont));
            }
            var result = KNumber.DoMath(a, b, (x, y) => x / y, (x, y) => x / y);

            if (result == null)
            {
                return(CPS.Error("/: wrong types", cont));
            }
            return(Return(result, cont));
        }