History (programming language)
The History data structure
Its behavior is very simplar to the queue. There are 2 primary operations: UPDATE, and INSERT.
The following table explains them, and shows how to implement them in History.
|UPDATE X||Update the current number as X, and put the previous "current number" into history.|
|INSERT X||Insert the backmost item to the index between index X and index X+1 without deleting the backmost item.|
|TOP X||Insert the top item to the index between X and X+1 without deleting the item.|
|ONSERT X||Put position X onto the top of the history without deleting the item.|
An example session of History
HISTORY: COMMAND: UPDATE 1 HISTORY: @UPDATE #1 is 1 COMMAND: UPDATE 2 HISTORY: @UPDATE #2 is 2 @UPDATE #1 is 1 COMMAND: INSERT 2 HISTORY: @UPDATE #3 is 1 @UPDATE #2 is 2 @UPDATE #1 is 1 COMMAND: BYE
It is not Turing-complete, of course. (It cannot execute an infinite loop.)