internal object ApplyToRight(IBinaryOperation op, object value) { IList <object> values = new List <object>(); foreach (var element in this.elements) { values.Add(op.Apply(value, element)); } return(new Vector(values)); }
private Vector ApplyOperation(IBinaryOperation op, Vector value) { IList <object> values = new List <object>(); int l1 = this.elements.Length; int l2 = value.Length; if (l1 < l2 && l2 % l1 != 0 || l1 > l2 && l1 % l2 != 0) { throw new InvalidOperationException("longer object length is not a multiple of shorter object length"); } int l = Math.Max(l1, l2); for (int k = 0; k < l; k++) { int k1 = k % l1; int k2 = k % l2; values.Add(op.Apply(this.elements[k1], value.elements[k2])); } return(new Vector(values)); }