public override Closure Apply(params Closure[] extra) { int arity = constructor.GetParameters().Length; int given = args.Length + extra.Length; if (arity > given) { Closure[] new_args = new Closure[given]; args.CopyTo(new_args, 0); for (int i = args.Length; i < given; i++) { new_args[i] = extra[i - args.Length]; } return(new PAPClosure(constructor, new_args)); } else { Closure[] new_args = new Closure[arity]; args.CopyTo(new_args, 0); for (int i = args.Length; i < arity; i++) { new_args[i] = extra[i - args.Length]; } Closure c = (Closure)constructor.Invoke(new_args); if (arity < given) { Closure[] other_args = new Closure[given - arity]; for (int i = 0; i < given - arity; i++) { other_args[i] = extra[i + arity - args.Length]; } c = c.Apply(other_args); } return(c); } }
public override Closure Apply(Closure c1, Closure c2, Closure c3) { Closure c = Eval(); return(c.Apply(c1, c2, c3)); }