X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=code%2Flambda.js;h=83ae7c4aea7d65d6250e5be5449a69ac0da4184f;hp=89bd21b59ed90b83bd222e1783eac952dd17d75d;hb=3c9d5a19d05c749c3bf4e05874bcb153db3a18c6;hpb=3a88ab1dea7db2189cbe9b72f2ec17986b8d199d diff --git a/code/lambda.js b/code/lambda.js index 89bd21b5..83ae7c4a 100644 --- a/code/lambda.js +++ b/code/lambda.js @@ -293,16 +293,16 @@ function Lambda_lam(variable, body) { return new Db_lam(this.body.debruijn(new_seq)); }; this.to_string = function (as_atom) { - var base = "\\" + this.to_string_funct(); + var base = "\\" + this.to_dotted(); if (as_atom) { return "(" + base + ")"; } else { return base; } }; - this.to_string_funct = function () { - if (this.body.to_string_funct) { - return this.bound.to_string() + " " + this.body.to_string_funct(); + this.to_dotted = function () { + if (this.body.to_dotted) { + return this.bound.to_string() + " " + this.body.to_dotted(); } else { return this.bound.to_string() + ". " + this.body.to_string(); } @@ -423,6 +423,7 @@ function reduce(expr, eta, cbv) { return expr.eval_cbv(cbv > 1); } else { // return expr.eval_loop([], eta); + // using trampoline to reduce call stack overflows var to_eval = expr, res = [[], eta]; while (to_eval !== null) { res = to_eval.eval_loop.apply(to_eval, res);