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


C# ScheminPair.Append方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: Execute

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

            applied = applied.Append(args.Car);
            applied = applied.Append(new ScheminContinuation(eval.Stack));

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

示例5: Execute

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

            ScheminPair letArgs = new ScheminPair();
            ScheminPair argExps = new ScheminPair();

            foreach (ScheminPair bindingPair in bindings)
            {
                letArgs = letArgs.Append(bindingPair.Car);
                argExps = argExps.Append(bindingPair.ElementAt(1));
            }

            ScheminPair body = new ScheminPair(new ScheminPrimitive("begin"));

            ScheminPair next = letArgs;
            ScheminPair nextExp = argExps;
            while (!next.Empty)
            {
                IScheminType symbol = next.Car;
                IScheminType exp = nextExp.Car;

                ScheminPair setExp = new ScheminPair(new ScheminPrimitive("set!"));
                setExp = setExp.Append(symbol);
                setExp = setExp.Append(exp);
                body = body.Append(setExp);

                next = next.ListCdr();
                nextExp = nextExp.ListCdr();
            }

            body = body.Append(expression);

            ScheminPair lambdaDef = new ScheminPair(letArgs);
            foreach (IScheminType type in body)
            {
                lambdaDef = lambdaDef.Append(type);
            }

            Environment closure = env;
            ScheminLambda lam = new ScheminLambda(lambdaDef, closure);

            ScheminPair toEvaluate = new ScheminPair(lam);
            foreach (IScheminType arg in argExps)
            {
                toEvaluate = toEvaluate.Append(new ScheminPair());
            }

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

示例6: 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

示例7: 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

示例8: 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

示例9: Execute

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

            if ((args as ScheminPair) != null)
            {
                ScheminPair temp = (ScheminPair) args;
                foreach (IScheminType type in temp)
                {
                    ret = ret.Append(type);
                }
            }
            else
            {
                ret = ret.Append(args);
            }

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

示例10: ToList

        public ScheminPair ToList()
        {
            ScheminPair list = new ScheminPair();

            foreach (IScheminType type in List)
            {
                list = list.Append(type);
            }

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

示例11: Execute

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

            ScheminPair pair = new ScheminPair();
            foreach (char c in str.Value)
            {
                pair = pair.Append(new ScheminChar(c));
            }

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

示例12: Parse

        public ScheminPair Parse(List<Token> tokens, bool quoteLists)
        {
            TransformQuoteTokens(tokens);
            int currentPosition = 0;

            ScheminPair totalParsed = new ScheminPair();
            while (currentPosition < tokens.Count)
            {
                totalParsed = totalParsed.Append(ParseTopLevel(tokens, ref currentPosition));
            }

            return totalParsed.Cons(new ScheminPrimitive("begin"));
        }
开发者ID:imphasing,项目名称:schemin,代码行数:13,代码来源:PairParser.cs

示例13: TestStringRef

        public void TestStringRef()
        {
            var prim = PrimitiveFactory.Get("string-ref");
            ScheminString test = new ScheminString("test");

            ScheminPair args = new ScheminPair(test);
            args = args.Append(new ScheminInteger(0));

            ScheminChar result = (ScheminChar) prim.Execute(null, null, args);
            char expected = 't';

            Assert.AreEqual(result.Value, expected);
        }
开发者ID:imphasing,项目名称:schemin,代码行数:13,代码来源:StringOperationTests.cs

示例14: Execute

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

            foreach (KeyValuePair<string, IScheminType> kvp in env.bindings)
            {
                var binding = new ScheminPair(AtomFactory.GetAtom(kvp.Key));
                binding = binding.Append(kvp.Value);

                bindings = bindings.Append(binding);
            }

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

示例15: Execute

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

            ScheminPair firstCondition = (ScheminPair) conditions.Car;
            if ((firstCondition.Car as ScheminAtom) != null)
            {
                ScheminAtom atom = (ScheminAtom) firstCondition.Car;
                if (atom.Name == "else")
                {
                    ScheminPair elseClause = firstCondition.ListCdr();
                    elseClause = elseClause.Cons(new ScheminPrimitive("begin"));

                    return elseClause;
                }
            }

            builtIf = builtIf.Append(new ScheminPrimitive("if"));
            builtIf = builtIf.Append(firstCondition.Car);

            ScheminPair beginExpression = firstCondition.ListCdr();
            beginExpression = beginExpression.Cons(new ScheminPrimitive("begin"));

            builtIf = builtIf.Append(beginExpression);

            if (conditions.ListCdr().Length > 0)
            {
                ScheminPair nextConditions = conditions.ListCdr();
                nextConditions = nextConditions.Cons(new ScheminPrimitive("cond"));

                builtIf = builtIf.Append(nextConditions);
            }

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


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