esolang

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

Expected: paper

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).

InstructionDoes
make 10 make 'H'Put a number or a character in the hand
take from incomingRead a character into the hand, 0 at the end
toss into outgoingPrint the hand as a character
toss into outgoing as intPrint the hand as a number
toss onto pilePut the hand on a pile
take off pile copy from pileTake the top of a pile into the hand, or copy it
add subtractAdd 1 to the hand, or take 1
bookmark nameMark this line
if nonzero then turn to nameGo to the bookmark when the hand is not 0
call name hang upGo to the bookmark, and come back
open book close book remarkStart, 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.

Expected: 30

A pile is a stack, so the Hello World puts its letters on the pile backwards, after a 0 that marks the end.

Expected: Hi

Patterns it teaches

Further

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 'abcdef'
shib manual secretary

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/secretary.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org