public static PineNA ZipEnd( PineNA first, PineNA second, PineNA third, PineNA fourth, PineNA fifth, PineNA sixth, PineNA seventh, PineNA eighth, Func <double?, double?, double?, double?, double?, double?, double?, double?, double?> result) { var fR = ((IEnumerable <double?>)first).Reverse(); var sR = ((IEnumerable <double?>)second).Reverse(); var tR = ((IEnumerable <double?>)third).Reverse(); var fH = ((IEnumerable <double?>)fourth).Reverse(); var fF = ((IEnumerable <double?>)fifth).Reverse(); var sX = ((IEnumerable <double?>)sixth).Reverse(); var sV = ((IEnumerable <double?>)seventh).Reverse(); var eG = ((IEnumerable <double?>)eighth).Reverse(); var fs = fR.Zip(sR, (s1, s2) => (s1, s2)); var tf = tR.Zip(fH, (s3, s4) => (s3, s4)); var f6 = fF.Zip(sX, (s5, s6) => (s5, s6)); var sE = sV.Zip(eG, (s7, s8) => (s7, s8)); var fstf = fs.Zip(tf, (f, s) => (f.s1, f.s2, s.s3, s.s4)); var fsse = f6.Zip(sE, (f, s) => (f.s5, f.s6, s.s7, s.s8)); var ret = fstf.Zip(fsse, (f, ff) => (f.s1, f.s2, f.s3, f.s4, ff.s5, ff.s6, ff.s7, ff.s8)); return(ret.Reverse().Select(x => result(x.s1, x.s2, x.s3, x.s4, x.s5, x.s6, x.s7, x.s8)).ToPineNA()); }
public static PineNA ValueWhen(PineNA condition, Pine source, uint occurrence = 0) { PineNA ret = new PineNA(); Queue <double> Queue = new Queue <double>(); foreach ((double?cond, double sour)tuple in ZipEnd(condition, source, (cond, sour) => (cond, sour))) { if (tuple.cond == null) { ret.Add(null); } else { Queue.Enqueue(tuple.sour); if (occurrence == 0) { ret.Add(Queue.Dequeue()); } else { ret.Add(null); occurrence--; } } } return(ret); }
public static PineNA ZipEnd(PineNA first, PineNA second, Func <double?, double?, double?> result) { var fR = ((IEnumerable <double?>)first).Reverse(); var sR = ((IEnumerable <double?>)second).Reverse(); var fs = fR.Zip(sR, (f, s) => (f, s)); return(fs.Reverse().Select(x => result(x.f, x.s)).ToPineNA()); }
public static PineNA operator /(double?number, PineNA pine) { PineNA ret = new PineNA(); foreach (double?num in pine) { ret.Add(number / num); } return(ret); }
public static PineNA operator -(PineNA pine, double?number) { PineNA ret = new PineNA(); foreach (double?num in pine) { ret.Add(num - number); } return(ret); }
public static PineNA IIF(PineBool pineBool, PineNA pineTrue, Pine pineFalse) { var bl = ((IEnumerable <bool>)pineBool).Reverse(); var tr = ((IEnumerable <double?>)pineTrue).Reverse(); var fl = ((IEnumerable <double>)pineFalse).Reverse(); var btf = bl.Zip(tr, (b, t) => (b, t)).Zip(fl, (bt, f) => (bt.b, bt.t, f)); return(btf.Reverse().Select(x => x.b ? x.t : x.f).ToPineNA()); }
public static PineNA IIF(PineBool pineBool, PineNA pineTrue, double?pineFalse) { var bl = ((IEnumerable <bool>)pineBool).Reverse(); var tr = ((IEnumerable <double?>)pineTrue).Reverse(); var fl = pineFalse; var bt = bl.Zip(tr, (b, t) => (b, t)); return(bt.Reverse().Select(x => x.b ? x.t : fl).ToPineNA()); }
public static PineNA IIF(PineBool pineBool, double?pineTrue, PineNA pineFalse) { var bl = ((IEnumerable <bool>)pineBool).Reverse(); var tr = pineTrue; var fl = ((IEnumerable <double?>)pineFalse).Reverse(); var bf = bl.Zip(fl, (b, f) => (b, f)); return(bf.Reverse().Select(x => x.b ? tr : x.f).ToPineNA()); }
public static PineNA ToPineNA(this IEnumerable <decimal?> source) { PineNA ret = new PineNA(); foreach (decimal?num in source) { ret.Add((double?)num); } return(ret); }
public static PineNA ZipEnd(PineNA first, PineNA second, PineNA third, PineNA fourth, Func <double?, double?, double?, double?, double?> result) { var fR = ((IEnumerable <double?>)first).Reverse(); var sR = ((IEnumerable <double?>)second).Reverse(); var tR = ((IEnumerable <double?>)third).Reverse(); var fH = ((IEnumerable <double?>)fourth).Reverse(); var fs = fR.Zip(sR, (f, s) => (s1: f, s2: s)); var tf = tR.Zip(fH, (t, f4) => (s3: t, s4: f4)); var fsrf = fs.Zip(tf, (f, s) => (f.s1, f.s2, s.s3, s.s4)); return(fsrf.Reverse().Select(x => result(x.s1, x.s2, x.s3, x.s4)).ToPineNA()); }
public static PineNA ZipEnd(PineNA first, PineNA second, PineNA third, PineNA fourth, PineNA fifth, PineNA sixth, PineNA seventh, Func <double?, double?, double?, double?, double?, double?, double?, double?> result) { var fR = ((IEnumerable <double?>)first).Reverse(); var sR = ((IEnumerable <double?>)second).Reverse(); var tR = ((IEnumerable <double?>)third).Reverse(); var fH = ((IEnumerable <double?>)fourth).Reverse(); var fF = ((IEnumerable <double?>)fifth).Reverse(); var sX = ((IEnumerable <double?>)sixth).Reverse(); var sV = ((IEnumerable <double?>)seventh).Reverse(); var fs = fR.Zip(sR, (s1, s2) => (s1, s2)); var tf = tR.Zip(fH, (s3, s4) => (s3, s4)); var f6 = fF.Zip(sX, (s5, s6) => (s5, s6)).Zip(sV, (f, s7) => (f.s5, f.s6, s7)); var fsrf = fs.Zip(tf, (f, s) => (f.s1, f.s2, s.s3, s.s4)).Zip(f6, (f, ff) => (f.s1, f.s2, f.s3, f.s4, ff.s5, ff.s6, ff.s7)); return(fsrf.Reverse().Select(x => result(x.s1, x.s2, x.s3, x.s4, x.s5, x.s6, x.s7)).ToPineNA()); }
Pine ValueWhen(PineNA condition, Pine source, uint occurrence) => TA.ValueWhen(condition, source, occurrence).ToPine(Enums.Approximation.Step);
public static PineNA Drop(this PineNA source, uint count) => source.Take(source.Count() - (int)count).ToPineNA();