Stoplight

From Esolang
Jump to navigation Jump to search

Stoplight is a 2-character language. All it does is prints letters.

Character Action
% Increase cell
# Print cell value as ASCII value and set cell to 0

It is a joke since it has no purpose and is really inefficient.

Example

Print ABC:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#

Print Hi:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%#
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#

Print 0:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#

Interpreter

Written in NodeJS. Probably a transpiler too.

function Stoplight(x){eval(x.replace(/[^%#]/g,"").replace(/(.)/g,"$1;").replace(/%/g,"++x").replace(/#/g,`OUTP`+"(String.fromCharCode((y=x,x=0,y)))").replace(/^/,"let y=x=0,OUTP=process.stdout.write;"));}

Another one in Free2Edit.

gcwsr1s%l1-cizl1+1r1ix+cr1s"+1l1-cizl1ocm1r1ixgcwe

In Python:

a=0;b=input();exec(.join("a+=1;"if i=='%'else"print(end=chr(a));a=0;"if i=='#'else""for i in b))