We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

J5h*t

From Esolang
Jump to navigation Jump to search

J5h*t is a very restricted subset to JavaScript developed by user:ais523 (and many others on PPCG) here, however the text and proof below is written by user:cleverxia. It only uses the characters +[]=`.

Basics

We encode numbers by this way: ++[++[...[++[+[]][+[]]][+[]]...][+[]]][+[]] because ++[x][+[]] returns x+1. To get characters we still use the method used by JSFuck: 'a'='false'[1]=(([]==[])+[])[1]=[[[]==[]][+[]]+[]][+[]][++[+[]][+[]]]. Because the literals false, true, NaN, undefined, Infinity can be generated by the set {{{1}}}, we have access to the characters INadefilnrstuy. To get more characters, we use the function representation of {{{1}}} which is function at() { [native code] } , together with the previous characters and the literal `+`, we get ( )+IN[]acdefilnorstuvy{} (note the space; .+- is technically possible but we does not need to use them), so we can spell constructor and get the constructors of NUmbers, Strings, Booleans, Arrays, Functions, giving ( )+BFINS[]abcdefgilmnorstuvy{}, so toString is available. Also, with ` we can call functions by f``, and with = we can do assignment. with constructor available, we can do [].at.constructor`...body...` to define a function (can't contain `'s); and we may replace toString for some object to call any function without `.

Turing completeness proof

we may simulate 2 counter minsky machines as follows:

[Array.c1=1 /*counter*/ ]+[Array.c2=1 /*counter*/ ]+[Array.a=1 /*state*/ ]+[Array.aa=1 /*branch goal state*/ ]+
[Array.no=Function`` /*NOP*/ ]+
[Array.c1a=Function`[Array.c1=1]+[Array.a=Array.aa]` /*restore c1 and branch*/ ]+
[Array.c2a=Function`[Array.c2=1]+[Array.a=Array.aa]` /*restore c2 and branch*/ ]+
[
[Array.t1=Function`[Array.c1=[Array.c1]]+[Array.a=q]`]+ //1 inc 1 q
[Array.t2=Function`[Array.c2=[Array.c2]]+[Array.a=q]`]+ //2 inc 2 q
[Array.t3=Function`[Array.c1=Array.c1[0]]+[Array.aa=fail]+[Array.a=succ]+
[Array.y=[]]+[Array.y.a=[Array.no]]+[Array.y.a[1]=Array.c1a]+[
Array.y.toString=Array.y.a[+[undefined==Array.c1][0]]]+[Array.y+[]]`]+ //3 dec 1 succ fail
                                                                       //... put all the states here
[]]+[Array.N=[]]+[Array.N.toString=Function`
[Array.I=[]]+[Array.f=[]]+[Array.f[1]=Array.t1]+...+[Array.f[n]=Array.tn]+
[Array.I.toString=Array.f[Array.a]]+[Array.I+[]]+[Array.N+[]]`]+[Array.N+[]]

halts by jumping to any out f bounds instruction and by throwing an error

This works by using nested list depths to store counters (JS Numbers are imprecise), [[...[1]...]] nested k times repersents value k; and we use the condition {{{1}}} to decide between 0 and nonzero (1[0] is undefined). We also use Array.a to store current state, and look it up in a big table then use the toString trick to execute it.

See also