示例#1
0
        public static SortedMap Create(System.Collections.IComparer comp, ISeq init)
        {
            IMap ret = new SortedMap(comp);

            for (; init != null; init = init.Next().Next())
            {
                if (init.Next() is null)
                {
                    throw new ArgumentException($"No value supplied for key: {init.First()}");
                }
                ret = ret.Assoc(init.First(), funclib.Core.Second(init));
            }
            return(ret as SortedMap);
        }
示例#2
0
        public static SortedMap Create(ISeq init)
        {
            IMap ret = EMPTY;

            for (; init != null; init = init.Next().Next())
            {
                if (init.Next() is null)
                {
                    throw new ArgumentException($"No value supplied for key: {init.First()}");
                }
                ret = ret.Assoc(init.First(), init.Next().First());
            }
            return(ret as SortedMap);
        }
示例#3
0
 static object ApplyTo(IFunctionParams <object, object, object, object, object, object> f, ISeq args) =>
 f.Invoke(
     args.First(),
     (args = args.Next()).First(),
     (args = args.Next()).First(),
     (args = args.Next()).First(),
     (object[])funclib.Core.ToArray(Ret((args = args.Next()), args = null)));
示例#4
0
 static object ApplyTo(IFunction <object, object, object, object, object, object> f, ISeq args) =>
 f.Invoke(
     args.First(),
     (args = args.Next()).First(),
     (args = args.Next()).First(),
     (args = args.Next()).First(),
     Ret((args = args.Next()).First(), args = null));
示例#5
0
 public object this[int index]
 {
     get
     {
         ISeq e = this;
         for (int i = 0; i <= index && e != null; ++i, e = e.Next())
         {
             if (i == index)
             {
                 return(e.First());
             }
         }
         throw new IndexOutOfRangeException(nameof(index));
     }
     set => throw new InvalidOperationException($"Cannot modify an immutable {nameof(ASeq)}.");
示例#6
0
 static object ApplyTo(IFunction <object, object> f, ISeq args) => f.Invoke(Ret(args.First(), args = null));