<commit_before>using System;

namespace Newmoon {
    public abstract class Closure {
	public Module module;

	public Closure(Module module) {
	    this.module = module;
	}

	public abstract object Apply(Continuation k);
	public abstract object Apply(Continuation k, object a);
	public abstract object Apply(Continuation k, object a, object b);
	public abstract object Apply(Continuation k, object a, object b, object c);
	public abstract object Apply(Continuation k, object a, object b, object c, object d);
	public abstract object ApplyVarargs(Continuation k, object[] args);
    }

    public abstract class Continuation {
	public Module module;

	public Continuation(Module module) {
	    this.module = module;
	}

	public abstract object Reply();
	public abstract object Reply(object a);
	public abstract object Reply(object a, object b);
	public abstract object Reply(object a, object b, object c);
	public abstract object Reply(object a, object b, object c, object d);
	public abstract object ReplyVarargs(object[] args);
    }

    public abstract class TailClosure: Closure {
	public TailClosure(Module module): base(module) {}

	public override object Apply(Continuation k) {
	    return ApplyVarargs(k, new object[] {});
	}
	public override object Apply(Continuation k, object a) {
	    return ApplyVarargs(k, new object[] {a});
	}
	public override object Apply(Continuation k, object a, object b) {
	    return ApplyVarargs(k, new object[] {a, b});
	}
	public override object Apply(Continuation k, object a, object b, object c) {
	    return ApplyVarargs(k, new object[] {a, b, c});
	}
	public override object Apply(Continuation k, object a, object b, object c, object d) {
	    return ApplyVarargs(k, new object[] {a, b, c, d});
	}
    }

    public abstract class TailContinuation: Continuation {
	public TailContinuation(Module module): base(module) {}

	public override object Reply() {
	    return ReplyVarargs(new object[] {});
	}
	public override object Reply(object a) {
	    return ReplyVarargs(new object[] {a});
	}
	public override object Reply(object a, object b) {
	    return ReplyVarargs(new object[] {a, b});
	}
	public override object Reply(object a, object b, object c) {
	    return ReplyVarargs(new object[] {a, b, c});
	}
	public override object Reply(object a, object b, object c, object d) {
	    return ReplyVarargs(new object[] {a, b, c, d});
	}
    }

    public class ToplevelContinuation: Continuation {
	public ToplevelContinuation(Module module): base(module) {}

	public override object Reply() {
	    return ReplyVarargs(new object[] {});
	}
	public override object Reply(object a) {
	    return a;
	}
	public override object Reply(object a, object b) {
	    return ReplyVarargs(new object[] {a, b});
	}
	public override object Reply(object a, object b, object c) {<commit_msg>Add non-tail-recursive apply implementation.<commit_after>using System;

namespace Newmoon {
    public abstract class Closure {
	public Module module;

	public Closure(Module module) {
	    this.module = module;
	}

	public abstract object Apply(Continuation k);
	public abstract object Apply(Continuation k, object a);
	public abstract object Apply(Continuation k, object a, object b);
	public abstract object Apply(Continuation k, object a, object b, object c);
	public abstract object Apply(Continuation k, object a, object b, object c, object d);
	public abstract object ApplyVarargs(Continuation k, object[] args);
    }

    public abstract class Continuation {
	public Module module;

	public Continuation(Module module) {
	    this.module = module;
	}

	public abstract object Reply();
	public abstract object Reply(object a);
	public abstract object Reply(object a, object b);
	public abstract object Reply(object a, object b, object c);
	public abstract object Reply(object a, object b, object c, object d);
	public abstract object ReplyVarargs(object[] args);
    }

    public abstract class TailClosure: Closure {
	public TailClosure(Module module): base(module) {}

	public override object Apply(Continuation k) {
	    return ApplyVarargs(k, new object[] {});
	}
	public override object Apply(Continuation k, object a) {
	    return ApplyVarargs(k, new object[] {a});
	}
	public override object Apply(Continuation k, object a, object b) {
	    return ApplyVarargs(k, new object[] {a, b});
	}
	public override object Apply(Continuation k, object a, object b, object c) {
	    return ApplyVarargs(k, new object[] {a, b, c});
	}
	public override object Apply(Continuation k, object a, object b, object c, object d) {
	    return ApplyVarargs(k, new object[] {a, b, c, d});
	}
    }

    public abstract class TailContinuation: Continuation {
	public TailContinuation(Module module): base(module) {}

	public override object Reply() {
	    return ReplyVarargs(new object[] {});
	}
	public override object Reply(object a) {
	    return ReplyVarargs(new object[] {a});
	}
	public override object Reply(object a, object b) {
	    return ReplyVarargs(new object[] {a, b});
	}
	public override object Reply(object a, object b, object c) {
	    return ReplyVarargs(new object[] {a, b, c});
	}
	public override object Reply(object a, object b, object c, object d) {
	    return ReplyVarargs(new object[] {a, b, c, d});
	}
    }

    public class ApplyTailClosure: TailClosure {
        public ApplyTailClosure(): base(null) {}

        public override object ApplyVarargs(Continuation k, object[] args) {
            Closure proc = (Closure) args[0];
            List tailList = (List) args[args.Length - 1];
            int extraCount = args.Length - 2;

            object[] newArgs = new object[tailList.ListLength() + extraCount];
            for (int i = 0; i < extraCount; i++) {
                newArgs[i] = args[i + 1];
            }
            int pos = extraCount;
            foreach (object e in tailList) {
                newArgs[pos++] = e;
            }
            return proc.ApplyVarargs(k, newArgs);
        }
    }

    public class ToplevelContinuation: Continuation {
	public ToplevelContinuation(Module module): base(module) {}

	public override object Reply() {
	    return ReplyVarargs(new object[] {});
	}
	public override object Reply(object a) {
	    return a;
	}
	public override object Reply(object a, object b) {
	    return ReplyVarargs(new object[] {a, b});
	}
	public override object Reply(object a, object b, object c) {
{'fraction_non_alphanumeric': 0.10310247571294265, 'fraction_numerical': 0.0007834534628643058, 'mean_word_length': 3.71070110701107, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7577731', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1826, 'n_words': 694}