From e4d4ec9e5fd38f64780b683c352c562f036fc5c0 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Tue, 26 Nov 2024 19:25:45 -0500 Subject: [PATCH] test stuff --- test.js | 116 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 95 insertions(+), 21 deletions(-) diff --git a/test.js b/test.js index 6694275..bad2047 100644 --- a/test.js +++ b/test.js @@ -1,4 +1,4 @@ -const elems = { +const elems = { '[]': 'Nothing', '["Nothing","Nothing"]': 'Null', '["Null","Nothing"]': 'Void', @@ -9,6 +9,9 @@ const elems = { '["Negative","Negative"]': 'Positive', '["Negative","Positive"]': 'Inverse', '["Inverse","Number"]': 'Fraction', + '["Positive","Positive"]': 'Addition', + '["Addition","Set"]': 'Union', + '["Union","Void"]': 'Expand', '["Fraction","Expand"]': 'Part', '["Number","Part"]': 'Digit', '["Digit","Expand"]': 'Letter', @@ -18,52 +21,114 @@ const elems = { '["Not","True"]': 'False', '["True","False"]': 'Boolean', '["Set","Boolean"]': 'Binary', + '["Set","Word"]': 'Statement', + '["Statement","Addition"]': 'Operator', '["Binary","Operator"]': 'Function', + '["Null","Number"]': 'Zero', '["Function","Zero"]': 'Algebra', + '["Inverse","Nothing"]': 'Everything', + '["Number","Everything"]': 'Infinity', + '["Inverse","Infinity"]': 'Infinitesimal', + '["Addition","Addition"]': 'Multiplication', + '["Inverse","Multiplication"]': 'Division', + '["Inverse","Addition"]': 'Subtraction', + '["Void","Subtraction"]': 'Distance', + '["Division","Distance"]': 'Slope', + '["Limit","Slope"]': 'Derivative', + '["Inverse","Derivative"]': 'Integral', + '["Derivative","Integral"]': 'Calculus', '["Algebra","Calculus"]': 'Mathematics', + '["Algebra","Infinitesimal"]': 'Limit', + '["Mathematics","Expand"]': 'Deabstraction', '["Mathematics","Deabstraction"]': 'Science', - '["Science","Combination"]': 'Chemistry', - '["Chemistry","Object"]': 'Chemical', + '["Science","Union"]': 'Chemistry', + '["Inverse","Set"]': 'Member', + '["Member","Everything"]': 'Thing', + '["Chemistry","Thing"]': 'Chemical', + '["Multiplication","Multiplication"]': 'Exponentation', + '["Multiplication","Exponentation"]': 'Recursion', + '["Recursion","Void"]': 'Pattern', '["Chemical","Pattern"]': 'Crystal', + '["Derivative","Deabstraction"]': 'Change', + '["Science","Change"]': 'Energy', + '["Energy","Chemimcal"]': 'Heat', + '["Not","Heat"]': 'Cold', '["Crystal","Cold"]': 'Rock', + '["Heat","Rock"]': 'Lava', + '["Heat","Lava"]': 'Plasma', + '["Heat","Plasma"]': 'Star', + '["Rock","Star"]': 'Planet', + '["Void","Rock"]': 'Air', + '["Air","Energy"]': 'Wind', '["Rock","Wind"]': 'Stone', '["Stone","Wind"]': 'Cobblestone', + '["Cobblestone","Wind"]': 'Sand', '["Cobblestone","Sand"]': 'Gravel', + '["Star","Chemical"]': 'Hydrogen', + '["Air","Hydrogen"]': 'Water', + '["Water","Void"]': 'Ocean', + '["Energy","Ocean"]': 'Life', '["Gravel","Life"]': 'Dirt', } const compCache = {}; const deCompCache = {}; -function indexr(n) { +function indexr(n, log_mode = false) { let j; try { j = JSON.parse(Object.keys(elems)[Object.values(elems).findIndex(x => x == n)]); } catch (err) { - return 0n; + return (log_mode) ? 1 : 0n; } - return comp(j); + + let c; + + c = comp(j, false, log_mode); + + if (!log_mode && c > (10n ** (10n ** 4n))) { + return 'oh no'; + } + + return c; } -function comp(e, ignore = false) { - if (!e || typeof e != 'object' || e.length == 0) return 0n; +function compSub(a,b,log_mode = false) { + let bb = (typeof a == 'bigint' && typeof b == 'bigint'); + if (log_mode && !bb) { + if (a < 100 && b < 100) { + a = 10 ** a; + b = 10 ** b; + return Math.log10((b * b + b) / 2 + a + 1); + } + return a * 2 + b * 2; + } else if (!log_mode && bb) { + return (b * b + b) / 2n + a + 1n; + } + + return 'oh no'; +} + +function comp(e, ignore = false, log_mode = false) { + if (!e || typeof e != 'object' || e.length == 0) return (log_mode) ? 0 : 0n; let a, b; if (ignore) { a = e[0]; b = e[1]; } else { let [j, k] = e; + a = compCache[`${j}.${log_mode}`] || indexr(j, log_mode); + compCache[`${j}.${log_mode}`] = a; - a = compCache[j] || indexr(j); - compCache[j] = a; - - b = compCache[k] || indexr(k); - compCache[k] = b; + b = compCache[`${k}.${log_mode}`] || indexr(k, log_mode); + compCache[`${k}.${log_mode}`] = b; } if (b > a) { - return (b * b + b) / 2n + a + 1n; + return compSub(a,b,log_mode); + } else if (a != 'oh no' && b != 'oh no') { + return compSub(b,a,log_mode); } else { - return (a * a + a) / 2n + b + 1n; + return 'oh no'; } } @@ -87,15 +152,15 @@ function decomp(e) { let s2 = compCache[s] || decomp(s); compCache[s] = s2; - let out = JSON.stringify([h2,s2]); + let out = JSON.stringify([h2, s2]); if (elems[out]) return elems[out]; - out = JSON.stringify([s2,h2]); + out = JSON.stringify([s2, h2]); if (elems[out]) return elems[out]; - return [h2,s2] + return [h2, s2] } function bsqrt(value) { @@ -119,12 +184,21 @@ function bsqrt(value) { } for (let i in elems) { - let compd = indexr(elems[i]); + let compd; + try { + compd = indexr(elems[i]).toString(10); + } catch (err) { + + } + + if (compd == 'oh no') { + compd = `10^(${indexr(elems[i],true)})`; + } compd += ''; let l = compd.length; - compd = compd.slice(0,Math.min(l,10)); + //compd = compd.slice(0, Math.min(l, 100)); - console.log(`${elems[i]}: ${compd}... (${l} digits)`) + console.log(`${elems[i]}: ${compd} (${l} chars)\n`) } \ No newline at end of file