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)); }
public object Step(object result, object input) { var key = keyFn(input); inputs[key] = inputs.ContainsKey(key) ? inputs[key] : new object[2] { key, valueAcc }; inputs[key][1] = valueFn.DynamicInvoke(inputs[key][1], input); return(result); }
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 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))); }
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)); }
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; })); }
public PromiseContinuation Then(Func <dynamic, dynamic> continuation) { return(new PromiseContinuation(f.DynamicInvoke <dynamic>(arguments).Result).Then(continuation)); }
private static dynamic ComplementInternal(DynamicDelegate fn) { return(Delegate((object[] arguments) => !fn.DynamicInvoke <bool>(arguments))); }