OLNMLN
OLNMLN or OneLineNoMoreLinesNeeded is a programming language where everything is written in one line! It was written by Grs (talk). It does borrow concepts from other languages (like a stack), but taken as a whole it's different. Originally it was just called OneLine, but that name is already taken up.
How it works
In OLNMLN a pointer is moved through your code. When the pointer stands on a character that is a command, the command will get executed. The pointer starts at the leftmost character and moves to the right, like a ball rolling down a hill. OLNMLN also contains a stack and a variable. The default value of the variable is None. Both of them can be used to store data. Every piece of data is either a string or a floating point number.
Commands
OLNMLN commands are 1 character, but if a value is needed, the characters after the command can define the data.
Command | Description | Example |
---|---|---|
s | Terminates program. | p0001p0002^s^ (prints: 2.0) |
ˇ | Pushes the character after it to the stack. If you want to push [newline] or [tab], use { or }. After execution, the pointer skips the character. | ˇHˇ{ˇ}ˇiˇ!^^^^^ (prints: !i<tabulator><newline>H |
p | Pushes the next four characters after it to the stack as one floating point number. After execution, the pointer skips the 4 digits. | p1234^ (prints: 1234.0) |
i | Makes the stack reversed. | ˇHˇiˇ!i^^^ (prints: Hi!) |
c | Duplicates the last item of the stack and pushes the duplicate to the stack | ˇHˇiˇ!ic^^^^ (prints: HHi!) |
+ | Pops the last 2 values from the stack, adds them together and pushes the total to the stack. If they are strings, they get combined. If one is a float and the other is a string, it does nothing. | p0001p0002+^ (prints: 3.0) |
- | Pops the last 2 values from the stack. The second to last value is took from the last value. The sum is pushed to the stack. If both is string, the command does nothing. Same if the two are string and float. | p0001p0002-^ (prints: 1.0) |
* | Pops the last 2 values from the stack, multiplies them together and pushes the total to the stack. If they are strings, nothing happens. If one is a float and the other is a string, the output will be a string that contains the string from the stack as many times as the number, but this only happens, if the float number can be converted to a interger. | p0002p0003*^ (prints: 6.0) |
/ | Pops the last 2 values from the stack. The last value is devided by the second to last last value. The sum is pushed to the stack. If both is string, the command does nothing. Same if the two are string and float. | p0002p0006*^ (prints: 3.0) |
% | Pops the last 2 values from the stack. The last value is (maybe) devided by the second to last last value. The remainder is pushed to the stack. If both is string, the command does nothing. Same if the two are string and float. | p0002p0006%^ (prints: 0.0) |
^ | Pops the last item from the stack and prints it to the console (floats can be outputted too). | p0001^ (prints: 1.0), ˇA^ (print: A) |
r | Pops the last item from the stack and does nothing with it. | p1324r (the stack after the r is empty) |
d | Pops the last item from the stack.
If the item is more than 0 or not a number, the command after d is skipped and the command after that is run, then the pointer continues moving. If the item is 0 or less, the pointer continues running the program. |
p0001dswIt works |
n | Pops the last item from the stack.
Makes the cursor jump the-popped-item's-value times (if it's one, it will just go to the next character). 0 makes it jump by 1 (so the pointer goes to the next character after d). UPDATE: If the item is a string, but it's only one character long, the pointer will jump by the characters ASCII code number. |
p0010np0001ˇH^^s (The program prints nothing.) |
> | Takes input from the user and puts it on top of the stack as a string. | >^ (The program prints what the user types in.) |
$ | It's like >, but if the input consists of digits, it will be converted into a float before pushing the value to the stack. | $dsp0001^ (If the user inputs 0 the program stops. If the user inputs 1 the program will print 1.0. 0 and 1 are not the only usable values for the d command) |
w | Takes the next 8 characters in the code and writes/prints them to the console. After execution, the pointer skips the 8 characters. | wHello Wowrld!<four space>(The spaces at the end are important!)(This program prints: Hello World!<four space>) |
j | Reads the next 4 characters as one number and jumps forward or backward that many times. After execution, the pointer skips the 4 digits. | j0006swDidn't!! (prints: Didn't!!) |
USE UPPERCASE LETTERS TO TELEPORT THE POINTER | When the pointer encounters a uppercase letter, it will try to search for the same uppercase letter
If it finds one, the cursor will jump to the code after it. The cursor will jump to the first uppercase letter it finds. If it doesn't find anything, it will continue the program. |
j0006A>^ˇ{^A (Cat program) |
# | Pops the last element of the stack and set's the variable to the value. | p0001#& (prints: 1.0) |
@ | Pushes the variable's value to the stack. The variable will NOT lose it's value. | p0000#.@^ (prints: 1.0) |
& | Prints the value of the variable. The variable will NOT lose it's value. | p0001#& (prints: 1.0) |
. | Adds 1.0 to the variable. | p0000#.@^ (prints: 1.0) |
, | Decreases the variable by 1.0. | p0000#,@^ (prints: -1.0) |
: | Pops the last element of the stack and adds it to the variable. | p0001#p0001:& (prints: 2.0) |
UPDATE | ||
= | Pops the last two items off of the stack and if they are equal, then the command after the = command is skipped. If not, the program continues. | >ˇa=ABAwNooooooosBwYessssss |
? | Takes a input and the characters of the input are pushed to the stack starting from the leftmost character. | ?p0000ij0006A^ˇ{^cdsA (prints each character of the input to a new line) |
} | Pops the last value off of the stack, converts it from string to float and pushes it back in. | ˇ1}^ (prints: 1.0) |
) | Pops the last value off of the stack, converts it from float to string and pushes it back in. | p0001p0001)i)+^ (prints: 1.01.0) |
Enters and tabulators do nothing. Spaces only matter at pushes. (ex. ˇ ) The program will otherwise just go over them.
The program can end if it reaches the code's end, so a stop command is not required.
Code examples
Hello World!
wHello Wowrld! ˇHˇeˇlˇlˇoˇ ˇWˇoˇrˇlˇdˇ!i^^^^^^^^^^^^ ˇ!ˇdˇlˇrˇoˇWˇ ˇoˇlˇlˇeˇH^^^^^^^^^^^^
Truth-machine
$dABAˇ0^sBˇ1j0006Cc^C
Cat program
j0006A>^ˇ{^A
FizzBuzz
p0001# j0006Ap0003@% ip0000i dXj0006Up0005@% dYj0006Id&.ˇ{^A XˇzˇzˇiˇF^^^^p0001+U YˇzˇzˇuˇB^^^^p0001+I
99 bottles of beer
Make sure that the two lines are copied to one line if you run the program!
p0099#j0006A&BD&CE,&FGˇ{^@dsABw bottlesw of beerw on the wwall ˇ{^D Cw bottlesw of beerˇ{^wtake onew down, pwass it awround ˇ{^EFw bottlesw of beerw on the wwall ˇ{^G
Deadfish interpreter
j0006A?p0000#p0000ij0006Fcˇi=GIGcˇd=HDHcˇs=JSJcˇo=KOKp0000=LALˇ{^rj0007Zr@p-001=QWQ@p0256=EREj0006YFI.ZD,ZS@@*#ZO&ZW.YRp0000#Y
Interpretation of code
An OLNMLN interpreter was written by Grs (talk) in Python and JavaScript. The code is on github