User:CarlosLuna
Jump to navigation
Jump to search
Carlos Luna-Mota is an esoteric programming language enthusiast from Catalonia.
He is currently interested in /// and Agony.
Contributions to ///
Unary to binary conversion
/ // /*/>01/ /1>/1/ /10/01/ /011/1\0/ /01/_1/ /_// />0/>/ />// **********************************
Unary to decimal conversion
/ // /*/>01/ /1>/1/ /10/01/ /01111111111/1\0/ /0111111111/_9/ /011111111/_8/ /01111111/_7/ /0111111/_6/ /011111/_5/ /01111/_4/ /0111/_3/ /011/_2/ /01/_1/ /_// />0/>/ />// ****************************************
Improved Thue-Morse sequence
/ // />*/#>/ />/\/.\/\/.0/ /#/\/.\\0\/,\\,0,\\,1\/\/.\\1\/,\\,1,\\,0\/\/,\\,\/.\// > ********
Improved Fibonacci sequence
/ // />*/#>/ />/\/.\/\/\/+\\+\/\/\/-\/\\\\\\\/\/\/0\/1\/\/1\/*\/++.1/ /#/\/.\\0\/,\\,0,\\,1\/\/.\\1\/,\\,0\/\/,\\,\/.\/\/+\\+\/=\\=.\\1-\/\/=\\=\/+\\+\// > *********
Binary Sums (work in progress)
/ // / // /Binary to unary conversion: Numbers with more than one digit"// /11/0*0*/ /10/0*0/ /01/00*/ /*1/*0*/ /*0/0**/ /0*/*/ /Binary to unary conversion: Add one or substract one// /+1/+*/ /-1/-*/ /Binary to unary conversion: Add zero or substract zero// /+0// /-0// /Change the negative number representation// /-*/#-/ /Remove plus and minus symbols// /#-/#/ /+// /Odd cases with a leading one or zero// /1#// /1*/**/ /0#/#/ /0\*/*/ /Cancel positive and negative unary numbers// /*#// /#*// /Unary to binary conversion// /#/-OI/ /I-/I/ /*/>OI/ /I>/I/ /IO/OI/ /OII/I\O/ /OI/_I/ /_// /Renove leading zeroes// /-O/-/ />O/>/ />// /Change binary representation digits// /I/1/ /O/0/ 1 - 1 + 0 - 10000 + 101 + 1 + 0 - 1 - 0 + 1011 - 10
Compact Python interpreter
def slashes(s): while s: buff = ["","",1] for t in (0,1,2): while s: if s[0] == "/" : s = s[1:]; break if s[0] == "\\": s = s[1:] if t: buff[t-1] += s[0]; s = s[1:] else: yield s[0]; s = s[1:] while s and buff[0] in s: s = s.replace(*buff)
Example of usage:
print("".join(slashes(r"/>*/#>//>/\/.\/\/.0//#/\/.\\0\/,\\,0,\\,1\/\/.\\1\/,\\,1,\\,0\/\/,\\,\/.\//>********")))
Fully-featured Python interpreter
def slashes(string, verbose=0, color=0): # Print Debug Info and Set Color Scheme ######################### if verbose > 0: output = []; print("INPUT: " + string + "\n") # if color <= 0: X = ["/", "/", "/", "\n"] # elif color == 1: X = ["\033[0;1m/\033[0;2m"]*3 + ["\033[0m\n"] # elif color >= 2: X = ["\033[0;2;90m/\033[0;91m", # "\033[0;2;90m/\033[0;92m", # "\033[0;2;90m/\033[0;96m", "\033[0m\n"] # ################################################################# while string: N = len(string) # Output whatever appears before the fist unescaped "/": i = 0 while i < N: if string[i] == "/" : break if string[i] == "\\": i += 1 ### Store Debug Info ##################### if verbose > 0: output.append(string[i]) # ########################################## yield string[i] i += 1 # Find the Pattern betwen the fist and the second unescaped "/": i, pattern = i+1, [] while i < N: if string[i] == "/" : break if string[i] == "\\": i += 1 pattern.append(string[i]) i += 1 # Find the Replacement betwen the second and the third unescaped "/": i, replacement = i+1, [] while i < N: if string[i] == "/" : break if string[i] == "\\": i += 1 replacement.append(string[i]) i += 1 # If there are less than three unescaped "/": halt if i >= N: break # Otherwise: perform as many Substitutions as possible pat = "".join(pattern) rep = "".join(replacement) string = string[i+1:] # Print Debug Info ########################################## if verbose > 1: # print("APPLY: "+X[0]+pat+X[1]+rep+X[2]+string+X[3]) # if verbose > 3: # _ = input("\nPress <Return> to resume execution") # print("\x1b[1A\x1b[2K\x1b[1A\x1b[2K\x1b[1A") # ############################################################# while pat in string: string = string.replace(pat, rep, 1) # Print Debug Info ########################################## if verbose > 2: # print("APPLY: "+X[0]+pat+X[1]+rep+X[2]+string+X[3]) # if verbose > 4: # _ = input("\nPress <Return> to resume execution") # print("\x1b[1A\x1b[2K\x1b[1A\x1b[2K\x1b[1A") # ############################################################# # Print Debug Info ################################## if verbose > 0: print("OUTPUT: " + "".join(output)) # #####################################################
Example of usage:
THUE_MORSE = r"""/ // />*/#>/ />/\/.\/\/.0/ /#/\/.\\0\/,\\,0,\\,1\/\/.\\1\/,\\,1,\\,0\/\/,\\,\/.\// > """ _ = "".join(slashes(THUE_MORSE+"*****", verbose=3, color=2))