当前位置: 首页>>代码示例>>C#>>正文


C# ScheminPair类代码示例

本文整理汇总了C#中ScheminPair的典型用法代码示例。如果您正苦于以下问题:C# ScheminPair类的具体用法?C# ScheminPair怎么用?C# ScheminPair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScheminPair类属于命名空间,在下文中一共展示了ScheminPair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            IScheminType first = args.Car;
            IScheminType second = args.ElementAt(1);

            return ScheminBool.GetValue(first.Equivalent(second));
        }
开发者ID:imphasing,项目名称:schemin,代码行数:7,代码来源:Eqv.cs

示例2: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            ScheminPort readFrom = eval.CurrentInputPort;

            if (args.Length > 0)
            {
                readFrom = (ScheminPort) args.Car;
            }

            StringBuilder built = new StringBuilder();
            char next;
            bool emptyInput = true;
            for (;;)
            {
                int nextRead = readFrom.InputStream.Read();
                next = (char) nextRead;

                if (nextRead == -1 || (next == '\n' && !emptyInput))
                {
                    break;
                }

                if (next != '\r')
                {
                    built.Append(next);
                    emptyInput = false;

                }
            }

            return new ScheminString(built.ToString());
        }
开发者ID:imphasing,项目名称:schemin,代码行数:32,代码来源:ReadLine.cs

示例3: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            IScheminType head = args.Car;
            IScheminType rest = args.ElementAt(1);

            if ((rest as ScheminPair) != null && ((ScheminPair) rest).Proper)
            {
                ScheminPair temp = (ScheminPair) rest;

                if (temp.Empty)
                {
                    return new ScheminPair(head);
                }
                else
                {
                    ScheminPair consd = new ScheminPair(head);

                    foreach (IScheminType type in temp)
                    {
                        consd = consd.Append(type);
                    }

                    return consd;
                }
            }

            return new ScheminPair(head, rest);
        }
开发者ID:imphasing,项目名称:schemin,代码行数:28,代码来源:Cons.cs

示例4: CheckArguments

        public override void CheckArguments(ScheminPair args)
        {
            IScheminType first = args.Car;

            if ((first as ScheminPair) == null)
            {
                if (args.Length != 2)
                {
                    throw new BadArgumentsException("expected 2 arguments");
                }

                if ((first as ScheminAtom) == null)
                {
                    throw new BadArgumentsException("first argument must be a symbol");
                }
            }
            else
            {
                ScheminPair arguments = (ScheminPair) args.Car;
                IScheminType name = arguments.Car;

                if ((name as ScheminAtom) == null)
                {
                    throw new BadArgumentsException("must supply a symbol for definition");
                }

                return;
            }
        }
开发者ID:imphasing,项目名称:schemin,代码行数:29,代码来源:Define.cs

示例5: CheckArguments

        public override void CheckArguments(ScheminPair args)
        {
            IScheminType first = args.Car;
            IScheminType second = args.ElementAt(1);
            IScheminType third = args.ElementAt(2);

            if (args.Length != 3)
            {
                throw new BadArgumentsException("expected 3 arguments");
            }

            if ((first as ScheminString) == null)
            {
                throw new BadArgumentsException("first argument must be a string");
            }

            if ((second as ScheminInteger) == null)
            {
                throw new BadArgumentsException("second argument must be an integer");
            }

            if ((third as ScheminInteger) == null)
            {
                throw new BadArgumentsException("third argument must be an integer");
            }

            return;
        }
开发者ID:imphasing,项目名称:schemin,代码行数:28,代码来源:Substring.cs

示例6: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            ScheminPair nextCycle = new ScheminPair();
            nextCycle = nextCycle.Append(new ScheminPrimitive("and"));

            if (args.Car.BoolValue() == ScheminBool.False)
            {
                return ScheminBool.False;
            }

            if (args.Length == 1)
            {
                return args.Car.BoolValue();
            }
            else
            {
                bool first = true;
                foreach (IScheminType type in args)
                {
                    if (!first)
                    {
                        nextCycle = nextCycle.Append(type);
                    }

                    first = false;
                }
            }

            return nextCycle;
        }
开发者ID:imphasing,项目名称:schemin,代码行数:30,代码来源:And.cs

示例7: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            IScheminType key = args.Car;
            ScheminPair checks = args.ListCdr();

            foreach (IScheminType type in checks)
            {
                ScheminPair pairCase = (ScheminPair) type;
                IScheminType group = pairCase.Car;
                IScheminType result = pairCase.ListCdr().Car;

                if ((group as ScheminAtom) != null)
                {
                    ScheminAtom atomClause = (ScheminAtom) group;
                    if (atomClause.Name == "else")
                    {
                        return result;
                    }
                    else
                    {
                        throw new Exception("atom besides 'else' found in case statement");
                    }
                }

                ScheminPair pairGroup = (ScheminPair) group;
                foreach (IScheminType checkType in pairGroup)
                {
                    if (key.Equivalent(checkType))
                        return result;
                }
            }

            return new ScheminPair();
        }
开发者ID:imphasing,项目名称:schemin,代码行数:34,代码来源:Case.cs

示例8: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            ScheminChar chr = (ScheminChar) args.Car;

            int result = Convert.ToInt32(chr.Value);
            return new ScheminInteger(result);
        }
开发者ID:imphasing,项目名称:schemin,代码行数:7,代码来源:CharInteger.cs

示例9: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            ScheminPair bindings = (ScheminPair) args.Car;
            IScheminType expression = args.ElementAt(1);

            ScheminPair first = new ScheminPair();
            ScheminPair firstBinding = new ScheminPair(bindings.Car);

            first = first.Append(new ScheminPrimitive("let"));
            first = first.Append(firstBinding);

            if (bindings.Cdr != null)
            {
                ScheminPair nextLet = new ScheminPair(bindings.Cdr);
                nextLet = nextLet.Cons(new ScheminPrimitive("let*"));
                nextLet = nextLet.Append(expression);

                first = first.Append(nextLet);
            }
            else
            {
                first = first.Append(expression);
            }

            return first;
        }
开发者ID:imphasing,项目名称:schemin,代码行数:26,代码来源:LetStar.cs

示例10: TestDivide

        public void TestDivide()
        {
            var prim = PrimitiveFactory.Get("/");
            ScheminDecimal test_decimal = new ScheminDecimal(3.0m);
            ScheminInteger test_integer = new ScheminInteger(3);
            ScheminInteger test_divisor_int = new ScheminInteger(2);
            ScheminDecimal test_divisor_decimal = new ScheminDecimal(2);

            ScheminPair decimal_args = new ScheminPair(test_decimal);
            decimal_args = decimal_args.Append(test_divisor_decimal);

            ScheminPair int_args = new ScheminPair(test_integer);
            int_args = int_args.Append(test_divisor_int);

            ScheminPair mixed_args = new ScheminPair(test_integer);
            mixed_args = mixed_args.Append(test_divisor_decimal);

            ScheminDecimal decimal_result = (ScheminDecimal) prim.Execute(null, null, decimal_args);
            ScheminInteger int_result = (ScheminInteger) prim.Execute(null, null, int_args);
            ScheminDecimal mixed_result = (ScheminDecimal) prim.Execute(null, null, mixed_args);

            ScheminInteger expected = new ScheminInteger(1);

            Assert.AreEqual(1.5m, decimal_result.DecimalValue());
            Assert.AreEqual(expected.IntegerValue(), int_result.IntegerValue());
            Assert.AreEqual(1.5m, mixed_result.DecimalValue());
        }
开发者ID:imphasing,项目名称:schemin,代码行数:27,代码来源:NumericOperationTests.cs

示例11: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            ScheminPair appended = new ScheminPair();

            foreach (IScheminType type in args)
            {
                if ((type as ScheminPair) != null)
                {
                    ScheminPair temp = (ScheminPair) type;

                    if (temp.Empty)
                    {
                        continue;
                    }

                    foreach (IScheminType subType in temp)
                    {
                        appended = appended.Append(subType);
                    }
                }
                else
                {
                    throw new BadArgumentsException("all arguments must be lists");
                }
            }

            return appended;
        }
开发者ID:imphasing,项目名称:schemin,代码行数:28,代码来源:Append.cs

示例12: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            var first = (IScheminNumeric) args.Car;
            var candidate = first.IntegerValue();

            if ((candidate & 1) == 0)
            {
                if (candidate == 2)
                {
                    return ScheminBool.True;
                }
                else
                {
                    return ScheminBool.False;
                }
            }

            for (BigInteger i = 3; (i * i) <= candidate; i += 2)
            {
                if ((candidate % i) == 0)
                {
                    return ScheminBool.False;
                }
            }

            return ScheminBool.GetValue(candidate != 1);
        }
开发者ID:imphasing,项目名称:schemin,代码行数:27,代码来源:Prime.cs

示例13: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            ScheminVector vec = (ScheminVector) args.Car;
            ScheminInteger pos = (ScheminInteger) args.ListCdr().Car;

            int pos_int = (int) pos.IntegerValue();
            return vec.List[pos_int];
        }
开发者ID:imphasing,项目名称:schemin,代码行数:8,代码来源:VectorRef.cs

示例14: Rewrite

        public ScheminPair Rewrite(ScheminPair values)
        {
            ScheminPair call = new ScheminPair(Rewriter);
            call = call.Append(new ScheminPair(new ScheminPrimitive("quote")).Append(values));
            call = call.Append(new ScheminPrimitive("create-closed-symbol"));

            return call;
        }
开发者ID:imphasing,项目名称:schemin,代码行数:8,代码来源:ScheminRewriter.cs

示例15: Execute

        public override IScheminType Execute(Environment env, Evaluator eval, ScheminPair args)
        {
            ScheminPair pair = (ScheminPair) args.Car;
            IScheminType val = args.ElementAt(1);

            pair.Car = val;
            return new ScheminPair();
        }
开发者ID:imphasing,项目名称:schemin,代码行数:8,代码来源:SetCar.cs


注:本文中的ScheminPair类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。