Talk:PlusOrMinus
Jump to navigation
Jump to search
The interpreter for PlusIntMinus has a bug: It doesn't output anything when I pass the Hello World program to it. --None1 (talk) 12:29, 28 August 2023 (UTC)
- The interpreter was indeed broken; I have added a link to a working one. Thank you for bringing this to my attention. —User:PythonshellDebugwindow (talk) 16:45, 28 August 2023 (UTC)
I have seen your interpreter, it seems very compilcated, wouldn't this
function pim(program){ var x=0,output=''; while(program.length){ if(program[0]=='+'){ var a=0; program=program.slice(1); if(!'0123456789'.includes(program[0])){ x=(x+1)%256; }else{ while('0123456789'.includes(program[0])){ a=a*10+program.charCodeAt(0)-48; program=program.slice(1); } x=(x+a)%256; } }else if(program[0]=='-'){ output+=String.fromCharCode(x); x=(x+255)%256; program=program.slice(1); }else{ program=program.slice(1); } } return output; }
Minimized version:
function pim(e){for(var i=0,r="";e.length;)if("+"==e[0]){var l=0;if(e=e.slice(1),"0123456789".includes(e[0])){for(;"0123456789".includes(e[0]);)l=10*l+e.charCodeAt(0)-48,e=e.slice(1);i=(i+l)%256}else i=(i+1)%256}else e=("-"==e[0]&&(r+=String.fromCharCode(i),i=(i+255)%256),e.slice(1));return r}
work as well? --None1 (talk) 07:54, 29 August 2023 (UTC)
- Yes. —User:PythonshellDebugwindow (talk) 20:37, 29 August 2023 (UTC)