(HA)pple waITING
- WARNING: To understand this you need to understand how a Turing machine works.
(HA)pple waITING is like a Turing machine converted to a 'programming language' but without the 9000 states just to reverse 3 strings.
Examples
Hello world
&hello hello _ h,e,l,l,o,_,w,o,r,l,d r print :Multi-definition doesn't move while you're writing; print _ * .halt * print * * .outb * $print .outb * * r
Syntax
The syntax is: <Current State> <Current symbol> <Symbol> <State> <Direction>
- Current state:
- State where you will add the rule/transition (can be numbers or names)
- Current symbol:
- The symbol that we expect will head read (Put * to detect a symbol that was not specified. Put _ for space)
- Symbol:
- The new symbol of the current cell (Put * to don't change the symbol)
- State:
- The state that will be changed later (Put * to stay in the same state)
- Direction;
- Direction you will move the head (l (left), r (right) or * (don't move))
To write a comment just write the comment inside : and ;
New features
- Substates (States can have states called Substates)
- Keyword states (Keyword states are special states)
- Detect states (Detect if you executed a state or not)
- Multi-definition (You will see it later)
- Initial state change (You will see it later)
Substates
Substates as I already said, they are states of states.
- To make one write:
- -<State that will have a substate>:<Substate>
- To change the current state to a substate of a state just write:
- <State>.<Substate>
Examples:
- Write bye:
write _ * write.b * -write:b _ b write.y r -write:y _ y write.e r -write:e _ e .halt * :This will halt the program, I will explain later;
Keyword states
Keyword states are states but special, cannot be created by the user and they start with a point ".".
State | Description |
---|---|
.halt | Halt the program |
.outc | Output the current cell |
.outb | Output the current cell as an ASCII character |
.inc | Get user's input and store it in the current cell |
.inb | Get user's input and store it in the current cell as an ASCII value |
.die | Go to the last state executed before this. Substates doesn't count |
Detect states
Detect states is a feature to allow you to detect if you executed a specified state before this state. To detect you just need a different syntax: $<Current state> <Detecting state> <Symbol> <New state> <Direction>
- Detecting state:
- The state that we are detecting if it was executed later
Multi-definition
Multi-definition is a feature that allows you to change the value of multiple cells in one line. Multi-definition also need a different syntax: <Current State> <Current symbol> <New symbol>,<New symbol>,<New symbol>... <Direction> <State>
- New symbol:
- Symbols to write
- Direction:
- Now direction change of meaning, Direction now means the direction of how the cells will be write, if you put in New symbols something like: H,E,L,L,O you can decide if you want it left to right (H E L L O) or right to left (O L L E H), to decide just write "r" (Left to right) or "n" (Right to left)
Initial state change
You can change the initial state, at the start of the program the initial state is 0, but you can change it by writing: &<The new initial state>