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); }
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); }
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)));
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));
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)}.");
static object ApplyTo(IFunction <object, object> f, ISeq args) => f.Invoke(Ret(args.First(), args = null));