OLNMLNE

From Esolang
Jump to navigation Jump to search
Not to be confused with OLNMLN.

OLNMLNE or OneLineNoMoreLinesNeededinEntropy is a programming language that is almost the same as OLNMLN. It was written by Grs (talk). The difference is that, somewhat like Entropy, data in the stack can change when something is done with the stack. This is achieved AFTER the modification to the stack has been made.

How it works

It works the same as OLNMLN, but every time something has been done to the stack, the program goes through it's elements and essentially replace some of their characters by random ones.

Commands

The commands won't be listed here, since they are the same as OLNMLN commands. NOTE: If OLNMLN gets updated, OLNMLNE may not get those updates.

Code examples

Look for more code examples in the OLNMLN, but most of them will not really work.

Random character outputter
p0100#ˇaj0006Ai,@dBAB^

Sometimes the code will throw an error, but sometimes it generates a random character. You can also expand this:

Random string outputter
p1000#ˇaˇaˇaˇaˇaˇaˇaˇa+++++++j0006Ai,@dBAB^

Interpretation of code

A OLNMLNE interpreter was written by Grs (talk) in Python. The code (without comments and with minor tweaks)(Make sure to remove the text "REMOVE_THIS", but not the ' characters)(Make sure to copy the text under the code in place of COPY_TEXT_HERE):

import random

def run(code, debug_on=False, step_on = False):
    def debug(special='REMOVE_THIS'):
        if debug_on:
            print(code)
            print((' '*(pointer))+'^', pointer, STACK, VARIABLE, special)
    global STACK
    STACK = []
    VARIABLE = None
    pointer = 0

    def STACK_random():
        for i, value in enumerate(STACK):
            if random.choice((False, False, False, False, False, False, False, True)):
                new_value = 
                for j in str(value):
                    if random.choice((False, False, False, False, False, False, False, True)):
                        new_value += chr(random.randrange(32, 126))
                    else:
                        new_value += j
                if type(STACK[i]) == type(0.0):
                    try:
                        STACK[i] = new_value
                    except:
                        pass
                else:
                    STACK[i] = new_value


    while code[pointer] != 's':
        command = code[pointer]
        if command == 's':
            break

        elif command == 'ˇ':
            if code[pointer+1] == '{':
                STACK.append('\n')
            elif code[pointer+1] == '}':
                STACK.append('\t')
            else:
                STACK.append(code[pointer+1])
            STACK_random()
            pointer += 2
        elif command == 'p':
            STACK.append(float(code[pointer+1:pointer+5]))
            STACK_random()
            pointer += 5

        elif command == 'i':
            STACK.reverse()
            STACK_random()
            pointer += 1
        elif command == 'c':
            STACK.append(STACK[-1])
            STACK_random()
            pointer += 1
        elif command == '+':
            if not ((type(STACK[-1]) == type('REMOVE_THIS') and type(STACK[-2]) == type(1.0)) or (type(STACK[-1]) == type(1.0) and type(STACK[-2]) == type('REMOVE_THIS'))):
                STACK.append(STACK[-1]+STACK[-2])
                STACK_random()
                STACK.pop(-2)
                STACK_random()
                STACK.pop(-2)
                STACK_random()
            pointer += 1
        elif command == '-':
            if type(STACK[-1]) == type(STACK[-2]) == type(1.0):
                STACK.append(STACK[-1]-STACK[-2])
                STACK_random()
                STACK.pop(-2)
                STACK_random()
                STACK.pop(-2)
                STACK_random()
            pointer += 1
        elif command == '*':
            if not (type(STACK[-1]) == type(STACK[-2]) == type('REMOVE_THIS')):
                STACK.append(STACK[-1]*STACK[-2])
                STACK_random()
                STACK.pop(-2)
                STACK_random()
                STACK.pop(-2)
                STACK_random()
            pointer += 1
        elif command == '/':
            if type(STACK[-1]) == type(STACK[-2]) == type(1.0):
                STACK.append(STACK[-1]/STACK[-2])
                STACK_random()
                STACK.pop(-2)
                STACK_random()
                STACK.pop(-2)
                STACK_random()
            pointer += 1
        elif command == '%':
            if type(STACK[-1]) == type(STACK[-2]) == type(1.0):
                STACK.append(STACK[-1]%STACK[-2])
                STACK_random()
                STACK.pop(-2)
                STACK_random()
                STACK.pop(-2)
                STACK_random()
            pointer += 1

        elif command == '^':
            print(STACK.pop(), end='REMOVE_THIS')
            STACK_random()
            pointer += 1
        elif command == 'r':
            STACK.pop()
            STACK_random()
            pointer += 1
        elif command == 'd':
            temp = STACK.pop()
            STACK_random()
            if type(temp) == type(1.0):
                if temp > 0.0:
                    debug('BEFORE d SWITCH')
                    pointer += 2
                elif temp <= 0.0:
                    debug('BEFORE d SWITCH')
                    pointer += 1
            else:
                debug('BEFORE d SWITCH')
                pointer += 2
            debug('AFTER d SWITCH')
        elif command == 'n':
            temp = STACK.pop()
            STACK_random()
            if type(temp) == type(1.0):
                if temp == 0:
                    debug('BEFORE n SWITCH')
                    pointer += 1
                else:
                    try:
                        debug('BEFORE n SWITCH')
                        pointer += int(temp)
                    except:
                        pass
            debug('AFTER n SWITCH')

        elif command == '>':
            STACK.append(input())
            STACK_random()
            pointer += 1
        elif command == '$':
            temp = input()
            if temp.isdigit():
                STACK.append(float(temp))
            else:
                STACK.append(temp)
            STACK_random()
            pointer += 1
        elif command == 'w':
            print(code[pointer+1:pointer+9], end='REMOVE_THIS')
            pointer += 9
        elif command == 'j':
            debug('BEFORE j')
            pointer += int(code[pointer+1:pointer+5])
            debug('AFTER j')
        elif command == '#':
            VARIABLE = STACK.pop()
            STACK_random()
            pointer += 1
        elif command == '@':
            STACK.append(VARIABLE)
            STACK_random()
            pointer += 1
        elif command == '&':
            print(VARIABLE, end=)
            pointer += 1
        elif command == '.':
            VARIABLE += 1.0
            pointer += 1
        elif command == ',':
            VARIABLE -= 1.0
            pointer += 1
        elif command == ':':
            VARIABLE += STACK.pop()
            pointer += 1
        else:
            if command.isupper() and command.isalpha():
                found_pair = False
                for i in range(len(code)):
                    if i != pointer and code[i] == code[pointer] and not found_pair:
                        pointer = i+1
                        found_pair = True
                        debug('UPPERCASE')
            else:
                pointer += 1

        if pointer == len(code):
            break

        debug('AFTER RUN')
        if step_on:
            if input().lower() == 'exit':
                break
def main():
    run_program = True
    while run_program:
        code = input('\nOneLine in Entropy (to choose by options, type nothing and press enter)\n> ')
        if code == 'REMOVE_THIS':
            userinput = input('COPY_TEXT_HERE')
            if userinput.lower() == 'normal':
                run(input('> '))
            elif userinput.lower() == 'debug':
                run(input('> '), True)
            elif userinput.lower() == 'step':
                run(input('> '), step_on=True)
            elif userinput.lower() == 'stepdebug':
                run(input('> '), True, True)
            elif userinput == :
                run_program = False
        else:
            run(code)
if __name__ == '__main__':
    main()

Text to copy in place of COPY_TEXT_HERE:
Normal mode (type "normal")\nDebug mode (type "debug")\nStep-by-step normal mode (type "step", when in mode, press enter to step, to exit running code type "exit" and press enter)\nStep-by-step debug mode (type "stepdebug", when in mode, press enter to step, to exit running code type "exit" and press enter)\nExit (type nothing)\n
(Please don't change the text above)

See also