public static Arrow <A, D> LiftA2 <A, B, C, D>(Func <B, C, D> op, Arrow <A, B> a1, Arrow <A, C> a2) { /* * Applies two arrows in parallel on the same input and then uses the supplied binary * operator to give a single output from the two results. */ return(Split <A>().Combine(a1.And(a2)).Combine(Unsplit(op))); }
public static Arrow <A, Tuple <C, D> > Fanout <A, B, C, D>(this Arrow <A, B> input, Arrow <B, C> a1, Arrow <B, D> a2) { /* * Applies the input to two arrows in parallel and gives the result as a tuple */ // TODOL Check Fanout works for invertible arrows return(input.Split().Combine(a1.And(a2))); }
public void InitialiseCircleArrow(int xRadius, int yRadius, int cX, int cY) { Arrow <int, Tuple <int, int> > timeDup = Op.Split <int>(); Arrow <int, double> sin = Op.Arr((int x) => cX + xRadius * Math.Sin((double)x / 20)); Arrow <int, double> cos = Op.Arr((int y) => cY + yRadius * Math.Cos((double)y / 20)); Arrow <Tuple <int, int>, Tuple <double, double> > sinCos = sin.And(cos); Arrow <double, int> doubleToInt = Op.Arr((double x) => (int)x); Arrow <Tuple <double, double>, Tuple <int, int> > adapter = doubleToInt.And(doubleToInt); circle = timeDup.Combine(sinCos).Combine(adapter); }