From 83fe617a787a31abb19d0e58f4b39b41cb9ff1ad Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 7 Apr 2024 21:06:36 +0200 Subject: Cantor and more hihi --- main.js | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'main.js') diff --git a/main.js b/main.js index 119a523..6b005f3 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,5 @@ +let MAXRES = 2; + let errors = []; const error = (s) => { errors.push(s); @@ -461,7 +463,7 @@ const snf = (_t) => { const reduceLoop = (worker, root, _t) => { const stack = [{ ctx: root, t: _t }]; - for (let i = 0; stack.length > 0 && i < 4 ** 10; i++) { + for (let i = 0; stack.length > 0; i++) { // console.log(i, stack.length); let [{ ctx, t }] = stack.splice( Math.floor(Math.random() * stack.length), @@ -480,6 +482,10 @@ const reduceLoop = (worker, root, _t) => { try { t = snf(t); } catch (e) { + if (e.message == "too much recursion") + error( + "your term most probably has some logical error (e.g. by not converging to a screen); if not, lmk", + ); error(e); return null; } @@ -502,23 +508,7 @@ const reduceLoop = (worker, root, _t) => { stack.push({ ctx: drawBottomRight(worker, ctx, toColor(br)), t: br }); } else { // TODO: could we risk gnfing here? - drawAt(ctx.x, ctx.y, toColor(t)); + drawAt(worker, ctx.x, ctx.y, toColor(t)); } } }; - -/* interface */ - -// window.reductionMode.addEventListener("change", () => { -// const state = window.reductionMode.value; -// if (state === "auto") { -// window.slider.disabled = true; -// window.slider.style.opacity = 0; -// } else if (state === "slider") { -// window.slider.disabled = false; -// window.slider.style.opacity = 100; -// } else if (state === "click") { -// window.slider.disabled = true; -// window.slider.style.opacity = 0; -// } -// }); -- cgit v1.2.3