function tm(d,s,e,i,b,t,... r) { document.write(d, '
') if (i<0||i>=t.length) return var re=new RegExp(b,'g') write('*',s,i,t=t.split('')) var p={}; r.forEach(e=>((s,r,w,m,n)=>{p[s+'.'+r]={w,n,m:[0,1,-1][1+'RL'.indexOf(m)]}})(... e.split(/[ .:,]+/))) for (var n=1; s!=e; n+=1) { with (p[s+'.'+t[i]]) t[i]=w,s=n,i+=m if (i==-1) i=0,t.unshift(b) else if (i==t.length) t[i]=b write(n,s,i,t) } document.write('
') function write(n, s, i, t) { t = t.join('') t = t.substring(0,i) + '' + t.charAt(i) + '' + t.substr(i+1) document.write((' '+n).slice(-3).replace(/ /g,' '), ': ', s, ' [', t.replace(re,' '), ']', '
') } } tm( 'Unary incrementer', // s e i b t 'a', 'h', 0, 'B', '111', // s.r: w, m, n 'a.1: 1, L, a', 'a.B: 1, S, h' ) tm( 'Unary adder', 1, 0, 0, '0', '1110111', '1.1: 0, R, 2', // write 0 rigth goto 2 '2.1: 1, R, 2', // while (1) rigth '2.0: 1, S, 0' // write 1 stay halt ) tm( 'Three-state busy beaver', 1, 0, 0, '0', '0', '1.0: 1, R, 2', '1.1: 1, R, 0', '2.0: 0, R, 3', '2.1: 1, R, 2', '3.0: 1, L, 3', '3.1: 1, L, 1' )