OATMEAL
OATMEAL (Oat-Activated Tape-based Multiprogramming Engine At Last) is a programming language by User:BoundedBeans which prides itself on also being a short notation for oatmeal platters (You know, if you're having guests over and you want to serve them all oatmeal, but you want each bowl to be different...). It's based on a dream the author had in vivid detail.
Semantics
There is a tape of unbounded positive integers, but it has limited size at a time. The size can increase, but it starts out with zero cells. Cells must be inserted before anything is done. There is a data pointer, which can be on any cell, as well as directly after the last cell or directly before the first cell. If there are zero cells, there is only one place, which is where the first cell would go. When a cell is inserted, the pointer is placed on the new cell. There is also an instruction pointer.
Oatmeal
Each cell corresponds to a bowl of oatmeal. All new oatmeal bowls should start out empty. Any spoonfuls added should contain only oats and either milk or water, depending on preference, unless otherwise indicated by a cooking comment. The integer doesn't necessarily have any relation to what's in the bowl, but how it got there does. The data pointer, on the other hand, always corresponds to which bowl the cook is modifying. If the data pointer is after the last cell or before the first, the cook should not be modifying any bowl, except if a cell is inserted there, where the cook should make a new bowl of oatmeal and place it there. The instruction pointer has absolutely no relation; they start aligned, but any flow control instructions do not cause the cook to perform the flow control. The cook should always go instruction by instruction, always forwards, only making jumps when encountering semicolons or function calls.
Instructions
Character | Computer instruction | Cook instruction |
---|---|---|
> |
Move the data pointer right, wrapping from after the last cell to before the first cell. | Move to the bowl to the right. |
< |
Move the data pointer left, wrapping from before the first cell to after the last cell. | Move to the bowl to the left. |
^ |
Increment the current cell. | Add an additional spoonful of basic oatmeal to the current bowl. |
v |
Decrement the current cell. If it is already zero, no-op. | Take a spoonful out of the oatmeal. If it is already empty, no-op. You can do whatever you would like with this spoonful, including:
|
" |
Insert a cell at the position, moving all cells to the right one position. This command must be preceded by the > command, so that it can be more accurate to the dream this esolang was based on. The cell the pointer is at after this command will always be the cell created (even if the pointer is before the first cell or after the last cell!). | Make a new bowl of basic oatmeal and insert it here, moving all bowls to the right one position up. The bowl the chef is at after this command will always be the bowl created (even if the focus is before the first bowl or after the last bowl!). |
' |
Go-to the current cellth ' command in the range of the deepest nested area between / and \ (one-based), unless it is zero, where it should go to the command after the \. Does not jump if it directly follows /. This can jump into a loop nested within the current loop. | Add a handful of raisins to the current bowl. |
/code\ |
Creates an area for the ' command to work. These can be nested. A good way to make loops is /'code!!'\ . |
/: Add a teaspoon of cinnamon to the current bowl. \: Add a teaspoon of sugar to the current bowl. |
! |
Logical not. | Stir the current bowl for 15 seconds. |
& |
Zero the current cell and add its value to all other cells. | Take the bowl and divide it evenly between all other bowls. |
; |
No-op. | Works sort of like ' in code, but checks if there is any oatmeal in the current bowl. Also works with / and \. |
? |
No-op. | If there is oatmeal in the bowl, remove it. (This oatmeal should not be saved if there are any other ingredients in it, unless a cooking comment says which step to save it for.). If there is no oatmeal in the bowl, add a spoonful of oatmeal to it. |
[@text@] |
No-op, but is a comment for the programmer. | No-op. |
[$text$] |
No-op. | No-op, but is a comment for the cook. |
: |
Delete the current cell. | Serve, eat, throw away, or otherwise remove the bowl from the cooking process, never to return. |
~ |
Receive a number from input, put it in the current cell. If before the first cell or after the last, no-op. | If you're acting on a bowl and not off the tape, ask another person for their favorite number (You can add conditions to keep it reasonable.). Add that many spoonfuls to the bowl. |
` |
Same as ~, but as a unicode character. | Same as ~, but ask them for their favorite symbol. If it isn't in unicode, go through their list of second-favorite, third-favorite, fourth-favorite, etc. until you find a valid unicode character. |
_ |
Output as a number. | Refrigerate the current bowl for 30 seconds. |
- |
Output as a unicode character. | Microwave the current bowl for 30 seconds. |
% |
Mark the current cell as read-only. If it is already read-only, make it modifiable. | Mark the current bowl as read only. If it is already read-only, make it modifiable. |
{@text@code@} |
Defines a function with a name and contents. | Defines a function for the cook to execute. |
=@text= |
Calls the function with the specified name. | The chef should execute the function. Chefs do have a call stack, but because their jump instructions are different and there could be function calls between them, chefs may end up with a separate path for the call stack to follow. |
=$text= |
Imports the functions from another OATMEAL code file. | The chef should grab the recipe from the other file and remember that the functions in that file might be used in the recipe. |
=$$text= |
Executes the text as a command in the command-line. Temporarily halts execution until the command finishes. This allows command-line arguments. \cell(position)\ will be replaced with the number of the cell, while \ccell(position)\ will be replaced with the character. |
No-op. |
. |
Reserved to allow two future or custom commands to share the same character. |
Examples
Add two numbers of input
[$ Requires 2 bowls. $] >">"~<~&>_
The following incorrect code has been translated into a recipe:
[$ Requires 4 bowls. $] >">">">">>>^^^^^^^^>%>/'v>&<<v<%^^^^^^^^^%>&>!!'\<<vvvvvvvvv-!v>!v>!v>!v>>>^^^^^^^^^^>%>/'v>&<<v<%^^^^^^^^^^%>&>!!'\<<vvvvv-
Here's the recipe:
Ingredients: 1 cup oats 1 cup milk 1 teaspoon cinnamon 2 handfuls raisins 1 teaspoon sugar This recipe makes 4 bowls of oatmeal. Method: READ: Remember to not stir the bowls unless told to do so. The layering is very important to create texture with the tiny, tiny bit of magnetism that raisins impose on oats, which creates tiny invisible cracks in the oats. This magnetism only happens when the raisins have more potential energy than the oats (which requires they be at a higher altitude.) 1. Make really basic oatmeal with the oats and milk. The toppings will be added later. 2. Place two of the four bowls on the table. Ask someone for their two favorite numbers and add that many spoonfuls to each bowl (keep the numbers reasonable please). Note: This is a bit of a psychology trick. When you focus on one topic and then get asked an unrelated question, your brain unconsciously transfers some bias to the random question that comes from your current focus. In this case, people who are more hungry for oatmeal will generally give a higher number, which in this recipe means they get more oatmeal. If we just asked them how much they want, there could be kind dishonesty for various reasons (such as if they don't want to give you a hassle when asking for more), which could even be unconscious! So it's better to indirectly trick their brain so you know roughly how much they actually want. 3. Place the other two bowls. These MUST be placed later because the bowls being exposed to air for a few more minutes causes the slight flavor of the smell of your home to go into the oatmeal, causing it to taste homier. The bowls are going to interact later, so it won't just affect the flavor in two of them. DO NOT PUT ANY OATMEAL IN THE BOWLS YET (We need to let the bowls age a bit longer, but on the table to add another "dimension" to the homey flavor.) 4. We are going to ignore bowl 1 mostly for the rest of this recipe, apart from one instruction. 5. Take everything out of bowl 2 and divide it evenly among bowls 3 and 4. 6. Add cinnamon and one handful of raisins to bowl 3. Cinnamon for taste, raisins for texture and taste. 7. Take bowl 4 and divide it among bowls 2 and 3. The raisins are sandwiched between the oats on bowl 3, which causes an even split of cracked oats and uncracked oats. 8. Take a spoonful out of bowl 2. Keep the spoonful for the next step. 9. Ignore step 4's rules temporarily and add a spoonful to bowl 1. You should reuse the spoonful from bowl 2, since it shouldn't have any fix-ins in it at this point. Bowl 1 now contains one spoonful of plain oatmeal in a less homey bowl. The tiny particles left in the wake of the spoon occasionally drift to bowl 3, adding a bit of extra texture and homey air flavor to bowl 3. 10. Divide bowl 2 evenly between bowls 3 and 4. This creates the perfect ratio of uncracked oats to cracked oats in bowl 3. 11. Finally, we finalize bowl 3. Stir it for 30 seconds, then add the other handful of raisins, then add sugar. The layering creates a wonderful parfait-like oatmeal that is mathematically and scientifically perfect. Congrats! Bowl 3 is now the perfect oatmeal! Bowls 1, 2, and 4 are edible, but really were only carriers of ingredients for the steps. 12. You can modify bowl 1 for this step. Remove a spoonful from the middle of the top of bowl 1. This spoonful is the mathematically worst oatmeal, so it's best to throw it away. 13. Make sure to refrigerate bowl 1 for 30 seconds. It needs to be cold, otherwise the bowl will explode from the intense mathematical energy coming from bowl 3, since it's not thick enough to resist.