public Tuple(Tuple tuple) { if (tuple == null) throw new ArgumentNullException(nameof(tuple), "null initialize tuple"); _tuple = new object[tuple.Count]; tuple.GetArray().CopyTo(_tuple, 0); }
public override object Evaluate(Environment env) { Tuple tuple = new Tuple(Count); int count = 0; foreach (IAstNode node in this) tuple[count++] = node.Evaluate(env); return tuple; }
public static Tuple Add(object left, Tuple right) { if (right == null) throw new ArgumentNullException(nameof(right), "null right value"); Tuple result = new Tuple(right.Count + 1); result[0] = left; Array.Copy(right.GetArray(), 0, result.GetArray(), 1, right.Count); return result; }
public static object GetElement(Tuple tuple, int index) { if (tuple == null) throw new ArgumentNullException(nameof(tuple), "null tuple"); return tuple[index]; }
public static string TupleToString(Tuple tuple) { return tuple == null ? "" : new string(Array.ConvertAll(tuple.GetArray(), new Converter<object, char>(x => (char)x))); }
public static object[] TupleToArray(Tuple tuple) { if (tuple == null) throw new ArgumentNullException(nameof(tuple), "null tuple"); return tuple.GetArray(); }
public static Tuple Add(Tuple left, object right) { if (left == null) throw new ArgumentNullException(nameof(left), "null left value"); Tuple result = new Tuple(left.Count + 1); left.GetArray().CopyTo(result.GetArray(), 0); result[left.Count] = right; return result; }
public static Tuple Add(Tuple left, Tuple right) { if (left == null) throw new ArgumentNullException(nameof(left), "null left value"); if (right == null) throw new ArgumentNullException(nameof(right), "null right value"); Tuple result = new Tuple(left.Count + right.Count); Array.Copy(left.GetArray(), 0, result.GetArray(), 0, left.Count); Array.Copy(right.GetArray(), 0, result.GetArray(), left.Count, right.Count); return result; }