Secretary
A program is an instruction book, and a secretary works through it at her desk.
Wingpad, 2013 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Wingpad made Secretary in 2013. A program reads like orders for a secretary. She opens the book, takes a letter from the incoming tray, tosses it into the outgoing tray, puts paper on a pile and turns to a bookmark. The specification says a computer can run it too.
Read the story
She can be offended. An instruction written in ALL CAPS is ignored half of the time. Bookmarks in capitals she always respects.
The machine
The secretary holds one number in her hand. There are two piles, the left one (pile or lpile) and the right one (rpile).
| Instruction | Does |
|---|---|
make 10 make 'H' | Put a number or a character in the hand |
take from incoming | Read a character into the hand, 0 at the end |
toss into outgoing | Print the hand as a character |
toss into outgoing as int | Print the hand as a number |
toss onto pile | Put the hand on a pile |
take off pile copy from pile | Take the top of a pile into the hand, or copy it |
add subtract | Add 1 to the hand, or take 1 |
bookmark name | Mark this line |
if nonzero then turn to name | Go to the bookmark when the hand is not 0 |
call name hang up | Go to the bookmark, and come back |
open book close book remark | Start, stop, a comment |
The full definitions were on the author's own site, with an array of memory cells as well. The specification shows only the instructions above, so this implementation is a subset of the language.
Example
The cat stops at a 0, or at the end of the input.
The cat stops at a 0, or at the end of the input.
A function call. The left pile gets 10 and 20, and add moves one from the first to the second until the first is 0. That is why the specification warns it cannot handle negatives.
A pile is a stack, so the Hello World puts its letters on the pile backwards, after a 0 that marks the end.
Patterns it teaches
- Camouflage: the program is an office manual.
- Stack machines: two piles, which is enough for any computation.
Further
See also
Cell-based
Stack-based
Write your own in Run Convert a program from Secretary
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: secretary.
Command line
shib run secretary -e 'open book
take from incoming
bookmark loop
toss into outgoing
take from incoming
if nonzero then turn to loop
close book' --input 'abc def'