Struffoli

From Esolang
(Redirected from Cannoli)
Jump to navigation Jump to search

Struffoli is an esoteric programming language that was created by User:Zero player rodent. The instruction pointer in Struffoli moves to different instructions in a way that requires code to be arranged in a specific order for it to work properly.

Description

In Struffoli, the instructions are stored in multiple memory cells. The instruction pointer starts one memory cell ahead of the last instruction to the right in the program. The instruction pointer moves to different instructions in this order:

Move backwards 2 cells, execute instruction.
Move forward 1 cell, execute instruction.
Move backwards 1 cell.

It will repeat that pattern until the program terminates. One way to make programs in Struffoli is to write the program normally, and then reverse it and rearrange the instructions.

Commands

Command Outcome
0 Increment the accumulator.
1 Push 0 onto the stack.
2 Add a value equal to the number stored in the accumulator to the value at the top of the stack.
3 Print the ASCII character associated with the value on the top of the stack
4 Pop the value at the top of the stack off of the stack.
5 Move the instruction pointer forward an amount of times equal to the current value in the accumulator.
6 Push one byte of input onto the stack.
7 Move the instruction pointer backwards an amount of times equal to the current value in the accumulator.
8 Pop the value off of the top of the stack a random amount of times, the highest possible amount of times is equal to the value in the accumulator.
9 Push the value at the top of the stack to the top of the stack. (Duplicate the value at the top of the stack.)
! Set the value that is stored in the accumulator to 0.
@ Add the value in the accumulator to the value of the accumulator. (Multiply the value in the accumulator by 2.)
# Add the value at the top of the stack to the value at the top of the stack. (Multiply the value at the top of the stack by 2.)
$ Make the instruction pointer move backwards 2 times if the value at the top of the stack is equal to the value stored in the accumulator.
% Make the instruction pointer move backwards 2 times if the value at the top of the stack is not equal to the value stored in the accumulator.
^ Terminate the program.
& Print the value at the top of the stack.

Note that when the commands "$" and "%" move the instruction pointer, the language will interpret the instruction in the memory cell it moved on without moving in the pattern first, unless the instruction in the memory cell is a "$" or "%". Also note that when the command "5" moves the instruction pointer forward, the language will not move the pointer according to the movement pattern before interpreting the command in the cell it is on unless the command is numerically lower than 5, or if the command is "$" or "%".

Code Examples

Program that prints "Hello".

39200!033020@30022!@@002!@2@0003!02!0#222@2@000

Truth machine.

539003!06%00000000@0@@@000$^

Cat program.

596300

Program that counts infinitely.

5@@002&!0

Program that reverses input. (This program expects a newline at the end of input, and does not terminate.)

5343434343434343434546$0@0@!0

Slot machine game. Keep playing until you match 3 characters.

338380800009!0000!022@2@020222202!129220@0@
222202!10900002!220@0@222222109!22@2@020222
2109!0000!022@2@020222202!129220@0@222202!1


External resources

Interpreter