public Term Splice(Term a) { if (Spliceable(a)) { return(TermHelper.Create(Numerator, Denominator, Limits.Splice(a.Limits))); } throw new InvalidOperationException($"Cannot Splice {this} and {a}"); }
public override Term MultiplyWith(Term other) { var multipliedVals = TermHelper.MultiplyValues(this, other); var asdasdasdasd = Limits.BreakDown(other.Limits).First(lim => lim.IsWithin(Limits) && lim.IsWithin(other.Limits)); if (Limits is null) { return((Number)0); } return(TermHelper.Create(multipliedVals.Numerator, multipliedVals.Denominator, Limits)); }
public override Term[] AddWith(Term other) { if (Spliceable(other)) { return new[] { Splice(other) } } ; if (!AffectedBy(other)) { return new[] { Clone(), other.Clone() } } ; var added = TermHelper.AddValues(this, other); if (Limits == other.Limits) { return new[] { TermHelper.Create(added.Numerator, added.Denominator, Limits) } } ; var tempList = new List <Term>(); foreach (var limits in Limits.BreakDown(other.Limits)) { var withinA = limits.IsWithin(Limits); var withinB = limits.IsWithin(other.Limits); if (withinA && withinB) { tempList.Add(TermHelper.Create(added.Numerator, added.Denominator, limits)); } else if (withinA) { tempList.Add(TermHelper.Create(Numerator, Denominator, limits)); } else if (withinB) { tempList.Add(TermHelper.Create(other.Numerator, other.Denominator, limits)); } } return(tempList.ToArray()); }