Beispiel #1
0
 internal XReduceBy(DynamicDelegate valueFn, object valueAcc, dynamic keyFn, ITransformer xf) : base(xf)
 {
     this.keyFn    = keyFn;
     this.valueFn  = valueFn;
     this.valueAcc = valueAcc;
     inputs        = new Dictionary <string, object[]>();
 }
        private static int AscendDescendInternal(dynamic firstOperator, dynamic secondOprator, dynamic fn, dynamic a, dynamic b)
        {
            DynamicDelegate dynamicDelegate = Delegate(fn);

            var aa = dynamicDelegate.DynamicInvoke <dynamic>(a);
            var bb = dynamicDelegate.DynamicInvoke <dynamic>(b);

            return(firstOperator(aa, bb) ? -1 : secondOprator(aa, bb) ? 1 : 0);
        }
        private static object BothOrEither(DynamicDelegate f, DynamicDelegate g, Func <Func <bool>, Func <bool>, bool> operand, dynamic liftBy)
        {
            if (f.IsNotNull())
            {
                return(Delegate((object[] arguments) => operand(() => f.DynamicInvoke <bool>(arguments), () => g.DynamicInvoke <bool>(arguments))));
            }

            return(Lift(liftBy)(f, g));
        }
        private static dynamic CreatePartialApplicator(DynamicDelegate concat)
        {
            return(Curry2(new Func <dynamic, IList, dynamic>((fn, args) => {
                return Arity(Math.Max(0, fn.Arity() - args.Count), Delegate((object[] arguments) => {
                    DynamicDelegate dynamicDelegate = Delegate(fn);
                    var concatedArgs = (IList)concat.DynamicInvoke(args, Arguments(arguments));

                    return dynamicDelegate.DynamicInvoke(concatedArgs.ToArray <object[]>(typeof(object)));
                }));
            })));
        }
        private static IList DropLastWhileInternal(dynamic pred, IList list)
        {
            var             idx             = list.Count - 1;
            DynamicDelegate dynamicDelegate = Delegate(pred);

            while (idx >= 0 && dynamicDelegate.DynamicInvoke <bool>(list[idx]))
            {
                idx -= 1;
            }

            return(list.Slice(0, idx + 1));
        }
Beispiel #6
0
        internal static DynamicDelegate Arity(int length, DynamicDelegate fn)
        {
            dynamic @delegate = fn;

            if (length <= 10)
            {
                return(DelegateN(new Func <object, object, object, object, object, object, object, object, object, object, object>((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) => @delegate(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)), length));
            }
            else
            {
                throw new ArgumentOutOfRangeException("Length", "First argument to Arity must be a non - negative integer no greater than ten");
            }
        }
        private static DynamicDelegate AnyOrAllPass(IList preds, bool comparend)
        {
            return(Delegate((object[] arguments) => {
                foreach (dynamic pred in preds)
                {
                    DynamicDelegate dynamicPred = Delegate(pred);

                    if (dynamicPred.DynamicInvoke <bool>(arguments) == comparend)
                    {
                        return comparend;
                    }
                }

                return !comparend;
            }));
        }
Beispiel #8
0
 internal XFindIndex(DynamicDelegate f, ITransformer xf) : base(f, xf)
 {
     idx = -1;
 }
Beispiel #9
0
 public CurryParams(DynamicDelegate fn) : base(fn, 2)
 {
 }
Beispiel #10
0
 /// <summary>
 /// Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returningfunction over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable),then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicativeinto an Applicative of Traversable.Dispatches to the `sequence` method of the third argument, if present.
 /// <para />
 /// sig: (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b)
 /// </summary>
 /// <param name="of">first</param>
 /// <param name="f">second</param>
 /// <param name="traversable">third</param>
 /// <returns>*</returns>
 /// <see cref="R.Sequence"/>
 public static dynamic Traverse(DynamicDelegate of, RamdaPlaceholder f = null, RamdaPlaceholder traversable = null)
 {
     return(Currying.Traverse(of, f, traversable));
 }
Beispiel #11
0
 internal AbstractXFn(DynamicDelegate f, ITransformer xf) : base(xf)
 {
     this.f = f;
 }
Beispiel #12
0
 internal Curry3(DynamicDelegate fn) : base(fn, 3)
 {
 }
Beispiel #13
0
 /// <summary>
 /// Provides a base class for specifying dynamic invocation behavior at run time
 /// </summary>
 public AbstractLambda(DynamicDelegate fn, int?length = null)
 {
     this.fn = fn;
     Length  = length ?? fn.Length;
 }
 private static dynamic ComplementInternal(DynamicDelegate fn)
 {
     return(Delegate((object[] arguments) => !fn.DynamicInvoke <bool>(arguments)));
 }
Beispiel #15
0
 internal XDropRepeatsWith(DynamicDelegate pred, ITransformer xf) : base(xf)
 {
     this.pred = pred;
 }
 private static DynamicDelegate CurryNInternal(int length, object[] received, DynamicDelegate fn)
 {
     return(new CurryN(fn, received, length));
 }
Beispiel #17
0
 /// <summary>
 /// Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returningfunction over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable),then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicativeinto an Applicative of Traversable.Dispatches to the `sequence` method of the third argument, if present.
 /// <para />
 /// sig: (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b)
 /// </summary>
 /// <param name="of">first</param>
 /// <param name="f">second</param>
 /// <param name="traversable">third</param>
 /// <returns>*</returns>
 /// <see cref="R.Sequence"/>
 public static dynamic Traverse <TTraversable>(DynamicDelegate of, DynamicDelegate f, TTraversable traversable)
 {
     return(Currying.Traverse(of, f, traversable));
 }
        private static IList TakeWhileInternal(int from, int indexerAcc, Func <int, bool> loopPredicate, DynamicDelegate fn, IList list, Func <int, int> sliceFrom, Func <int, int> sliceTo)
        {
            var idx = from;

            while (loopPredicate(idx) && fn.DynamicInvoke <bool>(list[idx]))
            {
                idx += indexerAcc;
            }

            return(list.Slice(sliceFrom(idx), sliceTo(idx)));
        }
Beispiel #19
0
 /// <summary>
 /// Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returningfunction over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable),then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicativeinto an Applicative of Traversable.Dispatches to the `sequence` method of the third argument, if present.
 /// <para />
 /// sig: (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b)
 /// </summary>
 /// <param name="of">first</param>
 /// <param name="f">second</param>
 /// <param name="traversable">third</param>
 /// <returns>*</returns>
 /// <see cref="R.Sequence"/>
 public static dynamic Traverse <TTraversable>(DynamicDelegate of, RamdaPlaceholder f, TTraversable traversable)
 {
     return(Currying.Traverse(of, f, traversable));
 }
 private static DynamicDelegate Dispatchable2(string[] methodNames, dynamic xf, DynamicDelegate fn)
 {
     return(Delegate(new Func <object, object, object>((arg1, arg2) => Dispatchable(methodNames, xf, fn, Arguments(arg1, arg2)))));
 }
Beispiel #21
0
 internal AbstractXTransform(DynamicDelegate f, ITransformer xf) : base(f, xf)
 {
 }
Beispiel #22
0
 public Curry3(DynamicDelegate fn) : base(fn, 3)
 {
 }
Beispiel #23
0
 internal XTakeWhile(DynamicDelegate f, ITransformer xf) : base(f, xf)
 {
 }
 internal static IComparer ToComparer(this DynamicDelegate @delegate, Func <object, object, int> comparator)
 {
     return(new ComparerFactory(comparator));
 }
Beispiel #25
0
 internal Curry2(DynamicDelegate fn) : base(fn, 2)
 {
 }
Beispiel #26
0
 internal Curry1(DynamicDelegate fn) : base(fn, 1)
 {
 }
Beispiel #27
0
 internal XFilter(DynamicDelegate f, ITransformer xf) : base(f, xf)
 {
 }
Beispiel #28
0
 public CurryN(DynamicDelegate fn, object[] received, int left) : base(fn, left) {
     this.received = received ?? new object[0];
 }
 internal PromiseLikeDynamicDelegate(AwaitableDynamicDelegate fn)
 {
     f      = fn;
     Length = 1;
 }
Beispiel #30
0
 internal XDropLstWhile(DynamicDelegate f, ITransformer xf) : base(f, xf)
 {
     this.f = f;
 }