public static Object LogXor(Cons args, Environment environment) { Type type = args.First().GetType(); object result = args.First(); foreach (Object item in (Cons)args.Rest()) { // The integral types dont define operator overload methods // for performace reasons, so we have to implement this // operator on each integral type if (type == typeof(sbyte)) { result = (sbyte)result ^ (sbyte)(item); } else if (type == typeof(byte)) { result = (byte)result ^ (byte)(item); } else if (type == typeof(char)) { result = (char)result ^ (char)(item); } else if (type == typeof(short)) { result = (short)result ^ (short)(item); } else if (type == typeof(ushort)) { result = (ushort)result ^ (ushort)(item); } else if (type == typeof(int)) { result = (int)result ^ (int)(item); } else if (type == typeof(uint)) { result = (uint)result ^ (uint)(item); } else if (type == typeof(long)) { result = (long)result ^ (long)(item); } else if (type == typeof(ulong)) { result = (ulong)result ^ (ulong)(item); } else { return(Runtime.Call("op_ExclusiveOr", args)); } } return(Convert.ChangeType(result, type)); }
public static Object Length(Cons args, Environment environment) { object o = args.Car(); if (o == null) { return(0); } else { return(Runtime.Call("length", args)); } }
public static Object Call(Cons args, Environment environment) { return(Runtime.Call(args.Car().ToString(), (Cons)Runtime.EvalList(args.Rest(), environment))); }