public override RecursionResult <KObject> Combine(KObject args, KEnvironment env, Continuation <KObject> cont) { int len = KPair.Length(args); if (len < 2 || len > 3) { return(CPS.Error("extend-continuation: argument mismatch", cont)); } KContinuation argC = First(args) as KContinuation; KApplicative argA = Second(args) as KApplicative; KEnvironment argE = len == 3 ? Third(args) as KEnvironment : new KEnvironment(); if (argC == null || argA == null || argE == null) { return(CPS.Error("extend-continuation: mismatching arguments", cont)); } var nc = new Continuation <KObject>((val, ctxt) => { return(CPS.Next(() => Evaluator.rceval(new KPair(argA.Combiner, val, true), argE, argC.Value), argC.Value)); }, argC.Value, argA); return(Return(new KContinuation(nc), cont)); }