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


C# ISeq.first方法代码示例

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


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

示例1: create

 /// <summary>
 /// Create a <see cref="PersistentHashSet">PersistentHashSet</see> initialized from an <see cref="ISeq">ISeq</see> of items.
 /// </summary>
 /// <param name="items">An <see cref="ISeq">ISeq</see> of items</param>
 /// <returns>A <see cref="PersistentHashSet">PersistentHashSet</see>.</returns>
 public static PersistentHashSet create(ISeq items)
 {
     PersistentHashSet ret = EMPTY;
     for (; items != null; items = items.next())
         ret = (PersistentHashSet)ret.cons(items.first());
     return ret;
 }
开发者ID:starapor,项目名称:clojure-clr,代码行数:12,代码来源:PersistentHashSet.cs

示例2: create

 public static PersistentHashSet create(ISeq items)
 {
     ITransientSet ret = (ITransientSet)EMPTY.asTransient(); 
     for (; items != null; items = items.next())
         ret = (ITransientSet)ret.conj(items.first());
     return (PersistentHashSet)ret.persistent();
 }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:7,代码来源:PersistentHashSet.cs

示例3: Parse

 public static Expr Parse(ISeq form)
 {
     Expr fexpr = Compiler.GenerateAST(form.first());
     IPersistentVector args = PersistentVector.EMPTY;
     for ( ISeq s = RT.seq(form.next()); s != null; s = s.next())
         args = args.cons(Compiler.GenerateAST(s.first()));
     return new InvokeExpr(Compiler.TagOf(form),fexpr,args);
 }
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:8,代码来源:InvokeExpr.cs

示例4: Parse

 public static Expr Parse(ISeq form)
 {
     Expr fexpr = Compiler.GenerateAST(form.first(),false);
     IPersistentVector args = PersistentVector.EMPTY;
     for ( ISeq s = RT.seq(form.next()); s != null; s = s.next())
         args = args.cons(Compiler.GenerateAST(s.first(),false));
     return new InvokeExpr((string)Compiler.SOURCE.deref(),(int)Compiler.LINE.deref(),Compiler.TagOf(form),fexpr,args);
 }
开发者ID:starapor,项目名称:clojure-clr,代码行数:8,代码来源:InvokeExpr.cs

示例5: VerifyISeqContents

        public void VerifyISeqContents(ISeq s, IList<object> values)
        {
            int i=0;

            for (; s != null; s = s.rest(), i++)
                Expect(s.first(), EqualTo(values[i]));

            Expect(i, EqualTo(values.Count));
        }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:9,代码来源:ISeqTestHelper.cs

示例6: construct

 /// <summary>
 /// Create a struct from a struct definition and values (in order) for the fixed keys.
 /// </summary>
 /// <param name="def">A struct definition</param>
 /// <param name="valseq">A sequence of values for the fixed keys (in definition order).</param>
 /// <returns>A <see cref="PersistentStructMap">PersistentStructMap</see>.</returns>
 public static PersistentStructMap construct(Def def, ISeq valseq)
 {
     object[] vals = new object[def.Keyslots.count()];
     IPersistentMap ext = PersistentHashMap.EMPTY;
     for (int i = 0; i < vals.Length && valseq != null; valseq = valseq.rest(), i++)
     {
         vals[i] = valseq.first();
     }
     if (valseq != null)
         throw new ArgumentException("Too many arguments to struct constructor");
     return new PersistentStructMap(null, def, vals, ext);
 }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:18,代码来源:PersistentStructMap.cs

示例7: GatherMethods

        //static string[] InterfaceNames(IPersistentVector interfaces)
        //{
        //    int icnt = interfaces.count();
        //    string[] inames = icnt > 0 ? new string[icnt] : null;
        //    for (int i = 0; i < icnt; i++)
        //        inames[i] = SlashName((Type)interfaces.nth(i));
        //    return inames;
        //}

        //static string SlashName(Type t)
        //{
        //    return t.FullName.Replace(',', '/');
        //}

        #endregion

        #region Method reflection

        static void GatherMethods(
            Type st,
            ISeq interfaces,
            out Dictionary<IPersistentVector, IList<MethodInfo>> overrides,
            out Dictionary<IPersistentVector, IList<MethodInfo>> explicits)
        {
            overrides = new Dictionary<IPersistentVector, IList<MethodInfo>>();
            explicits = new Dictionary<IPersistentVector, IList<MethodInfo>>();

            GatherMethods(st, overrides);
            for (; interfaces != null; interfaces = interfaces.next()) {
                GatherMethods((Type)interfaces.first(), overrides);
                GatherInterfaceExplicits((Type)interfaces.first(),explicits);
            }
        }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:33,代码来源:NewInstanceExpr.cs

示例8: create

 /// <summary>
 /// Create a <see cref="PersistentHashMap">PersistentHashMap</see> initialized from 
 /// an <see cref="ISeq">ISeq</see> of alternating keys and values.
 /// </summary>
 /// <param name="items">An <see cref="ISeq">ISeq</see> of alternating keys and values.</param>
 /// <returns>A <see cref="PersistentHashMap">PersistentHashMap</see>.</returns>
 public static PersistentHashMap create(ISeq items)
 {
     IPersistentMap ret = EMPTY;
     for ( ; items != null; items = items.rest().rest() )
     {
         if ( items.rest() == null )
             throw new ArgumentException(String.Format("No value supplied for key: {0}", items.first()));
         ret = ret.assoc(items.first(), items.rest().first() );
     }
     return (PersistentHashMap)ret;
 }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:17,代码来源:PersistentHashMap.cs

示例9: FindKey

 // do we need this?
 protected static ISeq FindKey(object key, ISeq args)
 {
     while (args != null)
     {
         if (key == args.first())
             return args.next();
         args = RT.next(args);
         args = RT.next(args);
     }
     return null;
 }
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:12,代码来源:RestFn.cs

示例10: Parse

        public static Expr Parse(ParserContext pcon, ISeq form, string name)
        {
            ISeq origForm = form;

            FnExpr fn = new FnExpr(Compiler.TagOf(form));
            fn._src = form;

            if (((IMeta)form.first()).meta() != null)
            {
                fn._onceOnly = RT.booleanCast(RT.get(RT.meta(form.first()), KW_ONCE));
            }

            fn.ComputeNames(form, name);

            // Java: fn.objtype = Type.getObjectType(fn.internalName) -- makes no sense for us, this is ASM only.

            List<string> prims = new List<string>();

            try
            {
                Var.pushThreadBindings(RT.map(
                    Compiler.CONSTANTS, PersistentVector.EMPTY,
                    Compiler.CONSTANT_IDS, new IdentityHashMap(),
                    Compiler.KEYWORDS, PersistentHashMap.EMPTY,
                    Compiler.VARS, PersistentHashMap.EMPTY,
                    Compiler.KEYWORD_CALLSITES,PersistentVector.EMPTY,
                    Compiler.PROTOCOL_CALLSITES,PersistentVector.EMPTY,
                    Compiler.VAR_CALLSITES,Compiler.EmptyVarCallSites(),
                    Compiler.NO_RECUR,null));

                //arglist might be preceded by symbol naming this fn
                if (RT.second(form) is Symbol)
                {
                    Symbol nm = (Symbol)RT.second(form);
                    fn._thisName = nm.Name;
                    fn.IsStatic = false; // RT.booleanCast(RT.get(nm.meta(), Compiler.STATIC_KEY));
                    form = RT.cons(Compiler.FN, RT.next(RT.next(form)));
                }

                // Normalize body
                //now (fn [args] body...) or (fn ([args] body...) ([args2] body2...) ...)
                //turn former into latter
                if (RT.second(form) is IPersistentVector)
                    form = RT.list(Compiler.FN, RT.next(form));

                SortedDictionary<int, FnMethod> methods = new SortedDictionary<int, FnMethod>();
                FnMethod variadicMethod = null;

                for (ISeq s = RT.next(form); s != null; s = RT.next(s))
                {
                    FnMethod f = FnMethod.Parse(fn, (ISeq)RT.first(s),fn.IsStatic);
                    if (f.IsVariadic)
                    {
                        if (variadicMethod == null)
                            variadicMethod = f;
                        else
                            throw new Exception("Can't have more than 1 variadic overload");
                    }
                    else if (!methods.ContainsKey(f.RequiredArity))
                        methods[f.RequiredArity] = f;
                    else
                        throw new Exception("Can't have 2 overloads with the same arity.");
                    if (f.Prim != null)
                        prims.Add(f.Prim);
                }

                if (variadicMethod != null && methods.Count > 0 && methods.Keys.Max() >= variadicMethod.NumParams)
                    throw new Exception("Can't have fixed arity methods with more params than the variadic method.");

                if ( fn.IsStatic && fn.Closes.count() > 0 )
                    throw new ArgumentException("static fns can't be closures");

                IPersistentCollection allMethods = null;
                foreach (FnMethod method in methods.Values)
                    allMethods = RT.conj(allMethods, method);
                if (variadicMethod != null)
                    allMethods = RT.conj(allMethods, variadicMethod);

                fn._methods = allMethods;
                fn._variadicMethod = variadicMethod;
                fn.Keywords = (IPersistentMap)Compiler.KEYWORDS.deref();
                fn.Vars = (IPersistentMap)Compiler.VARS.deref();
                fn.Constants = (PersistentVector)Compiler.CONSTANTS.deref();
                fn.KeywordCallsites = (IPersistentVector)Compiler.KEYWORD_CALLSITES.deref();
                fn.ProtocolCallsites = (IPersistentVector)Compiler.PROTOCOL_CALLSITES.deref();
                fn.VarCallsites = (IPersistentSet)Compiler.VAR_CALLSITES.deref();

                fn._constantsID = RT.nextID();
            }
            finally
            {
                Var.popThreadBindings();
            }

            IPersistentMap fmeta = RT.meta(origForm);
            if (fmeta != null)
                fmeta = fmeta.without(RT.LINE_KEY).without(RT.FILE_KEY);
            fn._hasMeta = RT.count(fmeta) > 0;

            if (Compiler.IsCompiling || prims.Count > 0)
//.........这里部分代码省略.........
开发者ID:davidadsit,项目名称:clojure-clr,代码行数:101,代码来源:FnExpr.cs

示例11: applyTo

        public override object applyTo(ISeq args)
        {
            int reqArity = getRequiredArity();

            if (RT.BoundedLength(args, reqArity) <= reqArity)
                return AFn.ApplyToHelper(this, Util.Ret1(args, args = null));

            switch (reqArity)
            {
                case 0:
                    return doInvoke(Util.Ret1(args, args = null));
                case 1:
                    return doInvoke(args.first()
                            , Util.Ret1(args.next(), args = null));
                case 2:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 3:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 4:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 5:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 6:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 7:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 8:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 9:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 10:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 11:
                    return doInvoke(args.first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , (args = args.next()).first()
                            , Util.Ret1(args.next(), args = null));
                case 12:
//.........这里部分代码省略.........
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:101,代码来源:RestFn.cs

示例12: GatherMethods

        static void GatherMethods(
            Type st,
            ISeq interfaces,
            out Dictionary<IPersistentVector, List<MethodInfo>> overrides)
        {
            Dictionary<IPersistentVector, List<MethodInfo>> allm = new Dictionary<IPersistentVector, List<MethodInfo>>();
            GatherMethods(st, allm);
            for (; interfaces != null; interfaces = interfaces.next())
                GatherMethods((Type)interfaces.first(), allm);

            overrides = allm;
        }
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:12,代码来源:NewInstanceExpr.cs

示例13: createWithCheck

 public static PersistentHashSet createWithCheck(ISeq items)
 {
     ITransientSet ret = (ITransientSet)EMPTY.asTransient(); 
     for (int i = 0; items != null; items = items.next(), ++i)
     {
         ret = (ITransientSet)ret.conj(items.first());
         if (ret.count() != i + 1)
             throw new ArgumentException("Duplicate key: " + items.first());
     }
     return (PersistentHashSet)ret.persistent();
 }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:11,代码来源:PersistentHashSet.cs

示例14: create

 /// <summary>
 /// Create a <see cref="PersistentVector">PersistentVector</see> from an <see cref="ISeq">ISeq</see>.
 /// </summary>
 /// <param name="items">A sequence of items.</param>
 /// <returns>An initialized vector.</returns>
 public static PersistentVector create(ISeq items)
 {
     IPersistentVector ret = EMPTY;
     for (; items != null; items = items.next())
         ret = ret.cons(items.first());
     return (PersistentVector)ret;
 }
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:12,代码来源:PersistentVector.cs

示例15: create

 /// <summary>
 /// Create a <see cref="PersistentTreeMap">PersistentTreeMap</see> from a comparison method
 /// an <see cref="ISeq">ISeq</see> of alternating keys and values.
 /// </summary>
 /// <param name="comp">A comparison method.</param>
 /// <param name="items">The <see cref="ISeq">ISeq</see>  of alternating keys and values.</param>
 /// <returns>A <see cref="PersistentTreeMap">PersistentTreeMap</see>.</returns>
 public static PersistentTreeMap create(IComparer comp, ISeq items)
 {
     IPersistentMap ret = new PersistentTreeMap(comp);
     for (; items != null; items = items.rest().rest())
     {
         if (items.rest() == null)
             throw new ArgumentException(string.Format("No value supplied for key: %s", items.first()));
         ret = ret.assoc(items.first(), items.rest().first());
     }
     return (PersistentTreeMap)ret;
 }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:18,代码来源:PersistentTreeMap.cs


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